Turn on torches Based on Time of Day (using Enviro)

Hello, I have Enviro running my weather and time of day. I have found a script in Enviro that determines when to active day and night cycles. I would like to add my torches and lanterns to this cycle so that they turn on at night and off in morning. I’m still learning how to use c# which is making this a little out of my reach. I have tried several things online by piecing them together but it does not seem to work.

I believe the game objects name is “Fire” but I am unsure. I know that when I uncheck the box next to fire, it turns off the fire and its particle effect (children) but when I try to reference it, it errors. I have tried editing the enviro code as well as using another script to make my own, but can’t get either to work.

[107723-fire.png*_|107723]

Here is the code for the enviro day-night cycle:

using UnityEngine;
using System.Collections;

public class EnviroDayNightSwitch : MonoBehaviour {

	private Light[] lightsArray;

	void Start () {

		lightsArray = GetComponentsInChildren<Light> ();

		EnviroSky.instance.OnDayTime += () =>
		{
			Deactivate () ;
		};

		EnviroSky.instance.OnNightTime += () =>
		{
			Activate () ;
		};

		if (EnviroSky.instance.isNight)
			Activate ();
		else
			Deactivate ();
	}
	

	void Activate () 
	{
		for (int i = 0; i < lightsArray.Length; i++) {
			lightsArray *.enabled = true;*
  •  }*
    
  • }*

  • void Deactivate ()*

  • {*

  •  for (int i = 0; i < lightsArray.Length; i++) {*
    

_ lightsArray .enabled = false;_
* }*
* }*

}

_*

@ryandeimling
Now I realize this answer is several years late, but its a really easy combine \ fix. And I’m really ashamed that no one answer your extremly easy question. Do better guys!
Most fires are made using particle systems.
The reason why it 1/2 works for you is because its turning the Light on and off as thats the only thing is looking for. Easy fix for you is make another array. just dump the script on the main object, it looks at all the children
LIke so:

    using UnityEngine;
    using System.Collections;
        
    public class EnviroDayNightSwitch : MonoBehaviour {
        
    private Light[] lightsArray;
    private ParticleSystem[] PC_Array;
        	
        
    void Start () {
        
        		lightsArray = GetComponentsInChildren<Light> ();
    
        		//Adding Particle Arrays as well
        		PC_Array = GetComponentsInChildren<ParticleSystem>();
        
        		EnviroSkyMgr.instance.OnDayTime += () =>
        		{
        			Deactivate () ;
        		};
        
        		EnviroSkyMgr.instance.OnNightTime += () =>
        		{
        			Activate () ;
        		};
        
        		if (EnviroSkyMgr.instance.IsNight())
        			Activate ();
        		else
        			Deactivate ();
        	}
        	
        
        	void Activate () 
        	{
        		for (int i = 0; i < lightsArray.Length; i++) {
        			lightsArray *.enabled = true;*
  •  }*
    

///Gets our new particles for the array like the light above it and turns them on

  •  for (int i = 0; i < PC_Array.Length; i++)*
    
  •  {*
    

PC_Array*.Play();
_
}_
_
}*_

* void Deactivate ()*
* {*
* for (int i = 0; i < lightsArray.Length; i++) {*
_ lightsArray .enabled = false;
* }*_

///Gets our new particles for the array like the light above it and turns them off

* for (int i = 0; i < PC_Array.Length; i++)
_ {_
PC_Array.Stop();
_ }
}
}*_