Hi All,
I’ve googled this and tried to cut and paste but the code examples to turn off layers won’t work whatever I do.
What I have is a camera on default layer. I have a cylinder on one layer a cube on the second. I’ve added my own layers and named them. Then used spacebar to hit and turn off.
The cube is on MiniGame01 layer it doesn’t vanish when I hot space.
voidUpdate()
{
if(Input.GetKeyDown("space"))
{
Camera.main.cullingMask |=(1<<LayerMask.NameToLayer("MiniGame01"));
}
}
So I tried using a print statement to view the culling mask. This shows -1 before and after cull.
voidUpdate()
{
if(Input.GetKeyDown("space"))
{
print(Camera.main.cullingMask);
Camera.main.cullingMask |=(1<<LayerMask.NameToLayer("MiniGame01"));
print(Camera.main.cullingMask);
}
}
from console
-1
UnityEngine.MonoBehaviour:print(Object)
TurnOffLayer:Update() (at Assets/Scripts/TurnOffLayer.cs:16)
-1
UnityEngine.MonoBehaviour:print(Object)
TurnOffLayer:Update() (at Assets/Scripts/TurnOffLayer.cs:16)
Can anyone advise on this?
Thanks