i have a culling mask with multiple Layers selected. for example: 0, 8, 9, 10
In game i create a second Camera that copies that culling mask, so i don´t / can´t predefine it in the inspector. The problem i can not solve is, how do i remove that single layer from my copied cullingmask. so the camera sees 0, 8, and 10.
I do not understand that bit shifting so i ask here, if someone can help me to remove that layer 9 from my copied culling mask.
public static int AddLayerToLayerMask(this int layerMask, int layer)
{
return layerMask | 1 << layer;
}
public static int RemoveLayerFromLayerMask(this int layerMask, int layer)
{
return layerMask & ~(1 << layer);
}
public static void AddLayerToCullingMask(this Camera camera, int layer)
{
camera.cullingMask |= 1 << layer;
}
public static void RemoveLayerFromCullingMask(this Camera camera, int layer)
{
camera.cullingMask &= ~(1 << layer);
}