Checking if layer is set in cullingMask

As many others I have problems wrapping my head around culling masks… :sweat_smile:
So I want to know if layer x is is set in a lights cullingMask. How to do it? I have searched, but couldn’t find stuff beynd hiow to change the culling mask to include (or exclude) x. But to check if x is present… :shock:

I need something like
If (x is present/set in cullingMask)…

SOLVED:

//To check if  a given layer is set in the culling mask
int layerToTestIfSet = 10;

if ((thisLight.cullingMask  (1 << layerToTestIfSet )) != 0) {
 DoWhatever();
}
1 Like

I will revive this from the archive but it helped me just now. Minor correction:

public bool IsLayerRendered(int layer)
    {
        return ((GetComponent<Camera>().cullingMask & (1 << layer)) != 0);
    }
1 Like