- Home /
How can I save the Bild from a Camera, which not main camera is.
I will get Texture2D from Rendertexture. The RenderTexture is Target Texture from seconde Camera.
GameObject com = GameObject.Find("Camera2"); RenderTexture myRenderTexture = com.renderer.material.mainTexture; Texture2D myTexture;
???????
byte[] bytes = myTexture.EncodeToPNG(); File.WriteAllBytes(Application.dataPath + "/../SavedView.png", bytes);
It will be easier to read if you put you code in code format. Select all the code and hit the numbers button in the edit panel.
Answer by Peter G · Apr 30, 2010 at 10:16 PM
Here's the answer on the forum. Unity Forum . Some of the variables are unexplained, but you can figure that if you declare the variables beforehand then you can probably figure it out. Take out the word thumb and you basically have the type of object it should be. Also it is written in Javascript but I only saw one or two lines that needed to be changed to work in C#.
Also check out Application.CaptureScreenShot. It won't capture the second camera, but I'm not sure what or how you are using the render texture so you may just want to run the game in the editor if you want a specific image and capture the screen.
Don't forget to mark it as the right answer if you think it is so that other people who see this post know the answer too.