Advice on Script Please

Noob here still learning coding I need help please.

I want a light to come on when my scene is at night, directional light off etc. Like a street light. Can anyone point me to right direction please. Thanks.

Sorry bad English

C#:

public GameObject SunLight; //Assign main Directional light here

void Update() {
   var sunState = SunLight.GetComponent<Light>.enabled;
   var lightState = gameObject.GetComponent<Light>.enabled;
   if (!sunState && !lightState) {
      gameObject.GetComponent<Light>.enabled = true;
   } else  if (sunState && lightState) {
      gameObject.GetComponent<Light>.enabled = true;
   }
}

Put this code into your street light.

1 Like

i love you NO HOMO