- Home /
Display individual UI elements on different layers
I have a Canvas rendered in World Space, which is set to the UI layer. I have multiple cameras in my scene, and they all display the UI, as expected.
I'd like to selectively choose UI elements (specifically, panels) of that canvas and control their visibility to certain cameras by placing them on a layer excluded from the culling mask of the corresponding camera. However, changing the layer of an individual UI element doesn't seem to have any effect on its visibility - I can only seem to do this by changing the layer of the canvas as a whole. Can anyone else confirm this, or am I doing something wrong?
Answer by MarkD · Jul 08, 2015 at 12:33 PM
Well, since their values are the same for every camera, I would say no. But you can however, create a OnpreRender script for each camera that needs separate control of the panel, change the value and change it back.
I use the same method to have a light source only light the scene for one camera (that renders to a render texture, so it renders all the same layers as my main camera).
Unity has a very good example of it on the reference page:http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnPreRender.html
This way you should be able to control the values per camera and have different results for each.
Your answer
![](https://koobas.hobune.stream/wayback/20220613200248im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Looking for picture in picture effect using Canvas Elements and Cinemachine follow target 0 Answers
How to put every modelpart in the correct layer in code? 0 Answers
Why canvas set to Screen Space - Overlay doesn't cover entire screen 0 Answers
HDRP Camera weapon layer 1 Answer
Why use different Canvas Render Modes 0 Answers