My point lights aren’t working properly and I can’t seem to find the problem. When I am playing in the editor all of my point lights break when I get a certain distance away from the light, although I’m still within range of the light. They go from lighting the player object normally to not lighting the player at all. This happens with all of my points lights, but only in a few scenes. The other scenes all seem to work just fine. In the editor I can fix the problem by clicking on anything in the Hierarchy or Scene view, but in a build there is nothing I can do to fix it.
Here is a picture from the editor right after the light turns off.
Here is the same view of the game right after I click on something in the Scene view.
This problem affects all of the points lights in the scene and when I click in the Scene view it fixes the problem for all of the point lights at once. I have no idea what the problem could be. The lights are instantiated through a script, but I have lights in working scenes instantiated the same way. Just in case it matters, here is the code for setting up the light after I have created it.
protected static void SetupLight(Light light)
{
light.type = LightType.Point;
light.color = new Color(1, 1, 1, 1);
light.attenuate = true;
light.range = 30;
light.renderMode = LightRenderMode.ForceVertex;
light.cullingMask = 0x01 << 8;
light.intensity = 1;
}