- Home /
Why does Camera.Render only work when rendering to RenderTextures
I'm not sure whether this is intentional or if I'm doing something wrong on my end but I can't seem to manually render to the game view. My scene consists of two cubes and a camera. I have this script attached to the camera;
public class CameraRenderTest : MonoBehaviour {
public GameObject ObjectA;
public GameObject ObjectB;
// Update is called once per frame
void Update () {
ObjectA.layer = 0;
ObjectB.layer = 9;
camera.Render();
ObjectA.layer = 9;
ObjectB.layer = 0;
camera.Render();
}
}
The Camera component is disabled to avoid automated rendering. I have the culling mask set to the default layer and the clear flag set to solid color. When I apply a RenderTexture to the camera both cubes are rendered to that texture along with the background. However if I leave the render texture field empty the game view stays blank. Again I'm not sure if this is a flaw with Unity or it was never intended handle what I'm attempting to do.
http://docs.unity3d.com/Documentation/ScriptReference/Camera.Render.html
Check the code example there. Camera.Render
renders to the RenderTexture.active
if the render texture is not specified.
Thanks! I guess I'll have to render to texture then project that onto something.
@powdered_swords Isn't that always the case? The camera renders something to a texture, which is then rendered onto the screen
Your answer
Follow this Question
Related Questions
Canvas interaction on render texture to message PhysicsRaycaster 1 Answer
Can a rendertexture be placed on top of an image? (Minimap help) 0 Answers
RenderTexture Mirror - Camera postion and rotation 1 Answer
RenderTexture and OnMouseEnter offset 0 Answers
How can I set the exact camera render size for render textures? 0 Answers