Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by CgShady · Jun 30, 2012 at 03:11 PM · editorrendertexturerendertotexture

RenderTexture not working when in Editor

I've come to a point where my code works when compiled and run as standalone, but not when running within the editor.

I was wondering if there is something wrong in my code, or a limitation of some sort that I missed maybe.

Using the following code will work when compiled, but not in the editor. It's not a problem, as long as you know it does work in the end...

 function TakePreview () {
 // creating a Texture to Render to
 var myRenderTexture = new RenderTexture(128, 96, 24);
 myRenderTexture.Create();
 
 // Setting the Camera to Render to the Texture
 Camera.main.targetTexture = myRenderTexture;
 
 // Setting the Texture to be the Active Texture to read from
 RenderTexture.active = myRenderTexture;
 
 // Creating a new Texture2D
 var myTexture2D = new Texture2D (128, 96, TextureFormat.RGB24, false);
 
 // Wait for the Frame to be fully rendered
 yield WaitForEndOfFrame();
 
 // Read pixels from the Render Texture into the Texture 2D
 myTexture2D.ReadPixels(new Rect(0, 0, myRenderTexture.width, myRenderTexture.height), 0, 0);
 myTexture2D.Apply();
 
 // Reset Camera and Release the RenderTexture
 Camera.main.targetTexture = null;
 RenderTexture.active = null;
 myRenderTexture.Release();

}

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Brocccoli · Jul 13, 2015 at 02:25 PM 0
Share

Where exactly does the code break? I'm not that experienced in Unity, but knowing what part of the method fails would help.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jaroslav-Stehlik · Jul 13, 2015 at 02:19 PM

I know this will not help, but I have the same exact problem on Unity 5.1.1f1 OSX

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Render Texture Black on Android Only 1 Answer

RenderTexture to create a movie very fast 1 Answer

RenderToCubemap with Image effect? 0 Answers

Do multiple viewpoints require Unity Pro? 1 Answer

RenderTarget in scripts 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges