I have the following simple script to hide everything on the layer of my choice.
var LayerToHide : LayerMask;
function Update () {
if(Input.GetKeyDown ("1"))
{
camera.cullingMask = ~LayerToHide.value;
}
}
I would simply like to be able to rest the camera, or show the culled layer.
Any thoughts?
A layer mask is treated as an array of bits so you need to use the bitwise operators to switch individual layers on and off. To activate a layer, you use:-
layerToHide.value = layerToHide.value | (1 << layerNum);
…and to hide it, use:-
layerToHide.value = layerToHide.value ~(1 << layerNum);
I wasn’t able to get that working exactly as is, but I figured it out.
var LayerToHide : LayerMask;
function Update () {
//hide
if(Input.GetKeyDown ("1"))
{
camera.cullingMask = ~LayerToHide.value;
}
//show
if(Input.GetKeyDown ("2"))
{
camera.cullingMask |= LayerToHide.value;
}
}
Thanks for your help!