Light culling mask issue

public class troubleshootLightCullingMask : MonoBehaviour {
   
    // Update is called once per frame
    void Update () {

        var _light = this.GetComponent<Light>();

        _light.cullingMask = int.MaxValue;
       
    }
}

When adding this script to a GameObject with light, the log file is flooded with the following warnings:

Too many layers used to exclude objects from lighting. Up to 4 layers can be used to exclude lights, while your lights use 5: ‘Default’ ‘UI’ ‘L16-SceneRealtime1’ ‘L24-CollectableItems+IgnoredByFlashlight’ ‘Unnamed 31’

It is not setting the the layer 31 bit:


.[/CODE]

NVRM.

int.MaxValue = 0x7FFFFFFF,
not 0xFFFFFFFF
hence the bit 31 is 0, not 1

Setting cullingMask = -1 solves the issue