0
\$\begingroup\$

I have a camera that renders a simple model to a RenderTexture. I then use that RenderTexture as a texture for my UI with a RawImage component. However, sometimes I disable my UI and therefore you can not see the RenderTexture.

My question is: Does the camera continue to render to the texture in the background even when the texture is not visible?

If I understand how this works I believe it should. If so, simply disabling the camera should prevent it from rendering in the background?

Thanks.

\$\endgroup\$
  • \$\begingroup\$ Your assumptions are, as far as I know, correct. One way to verify this is to run the game with the profiler, and check to see that the draw calls corresponding to your RenderTexture camera still occur when the RawImage component is disabled. You can also place an OnWillRenderObject script on the model's GameObject and report the value of Camera.current to confirm that your RenderTexture camera is still rendering it. Try one of these and feel free to report the results you find as an answer. \$\endgroup\$ – DMGregory Dec 12 '16 at 21:41
1
\$\begingroup\$

Just because a RenderTexture isn't being used as a texture or sprite, doesn't mean that it's not being rendered to. You can see this yourself if you locate your RenderTexture in your project tab, and look at the preview at the bottom of the inspector. You should see a live updating version of your texture.

The only way to prevent the Camera from drawing to the RenderTexture (that I'm aware of) is to disable the Camera, or remove the RenderTexture from the Camera's Target Texture field.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.