using UnityEngine;
using System.Collections;
public class Light_Manager : MonoBehaviour {
new GameObject[] light;
public float AmbientI;
// Use this for initialization
// Update is called once per frame
void Update() {
AmbientI = RenderSettings.ambientIntensity;
try
{
light = GameObject.FindGameObjectsWithTag("Light");
}
catch (System.NullReferenceException ex) {
light = GameObject.FindGameObjectsWithTag("Light");
}
if(AmbientI <= 1.1f) {
StartCoroutine(EnableBlockLight());
}
if(AmbientI > 1.1f) {
StartCoroutine(DisableBlockLight());
}
}
public IEnumerator EnableBlockLight() {
yield return new WaitForEndOfFrame();
foreach (GameObject a in light)
{
a.gameObject.SetActive(true);
}
}
public IEnumerator DisableBlockLight() {
yield return new WaitForEndOfFrame();
foreach (GameObject a in light)
{
a.gameObject.SetActive(false);
}
}
}
GamObject[] light; is prefab and instiantiate create in playing game.
my problem is if playing game, DisableBlockLight () function is working…
but EnableBlockLight() function is not working…
PS. ambientIntensity value is changing frequently…
Help to me please… thank you…