I'm working on a "split screen" mode of a game and I have some GUI elements that should appear in only one of the two cameras.
I have a quite regular NGUI hierarchy:
-UI Root
--MainCamera
---MainCameraClone
---SomePrefab
----Anchor1
----Anchor2
Except for MainCameraClone everything is like a generic NGUI tree. MainCameraClone is just a camera with the same attributes of MainCamera but with a different layer mask.
MainCamera can see layers "GUI" and "Player1" and MainCameraClone can see "GUI" and "Player2".
All objects have "GUI" as their layer, so their appear on both cameras.
I made a script to change the layer of the gameObject and all of its children, and attached it to Anchor2.
When I hit play I can see that the layer of Anchor2 and its children is different than GUI. Nevertheless the camera object appear on both camera.
It works when I add the script to SomePrefab instead of Anchor2, but I can't do that since Anchor1 must keep its original layer. And I don't want to separate the prefab in 2 because there are many prefabs.
So why do this happen? An object should be seen by the camera that can see its layer independent of the value of its parents layer, right?