- Home /
Camera only renders to textures once modified during Play (from Inspector)
I have two Cameras in my Scene. One is the default Main Camera, another is a Camera that I am using to render a batch of Meshes to a corresponding batch of RenderTextures, every frame. My code looks like:
//executed every frame
cam.targetTexture = renderTextureA;
Graphics.DrawMesh (renderMeshA, matrix, renderMaterial, layer, cam);
cam.Render();
cam.targetTexture = renderTextureB;
Graphics.DrawMesh (renderMeshB, matrix, renderMaterial, layer, cam);
cam.Render();
cam.targetTexture = renderTextureC;
Graphics.DrawMesh (renderMeshC, matrix, renderMaterial, layer, cam);
cam.Render();
Now, this all works perfectly, with the one caveat, that cam will only actually start rendering according to these calls once I have hit play, and modified one of its properties in the Inspector.
It does not matter which property I modify.
It starts working immediately upon modification of any of the properties.
Modifying one or more of its properties via script will not cause it to start working, it has to be done manually through the inspector.
This modification must be done during Play mode.
Has anyone ever run into anything like this? I can't find anything, either digging here or in the documentation for Camera or any of the classes it inherits from, all the way down to UnityEngine.Object.
Thanks.
Answer by HarmonicWave · Jan 31, 2017 at 08:36 PM
I had this happen with multiple cameras present. Fixed by setting the Depth of the camera that was not showing up to a higher number than the other(s).
Your answer
Follow this Question
Related Questions
Camera panning on pre-rendered backgrounds 2 Answers
Rendering the same Render Texture differently to separate cameras 0 Answers
Culling Mask with Depth Occlusion 1 Answer
Camera Screenshot 0 Answers