Avec le script suivant, je détecte la baisse "de la luminosité" de ma scène en récupérant le light de l'objet Sky Dome.
Si la luminosité baisse sous un seuil , mes spots s'allument.
Le script marche. J'ai ajouté un flare à mes spot mais celui-ci ne s'active pas .
Comment modifier le script svp car le flare est un élément des light mais comment le noter car ce n'est pas un component ?
Merci
Code : Tout sélectionner
using UnityEngine;
using System.Collections;
/* a mettre sur le groupe Lampadaires
* garder la hierarchie Lampadaires- LampadaireSimple et Lumières ou bien Spotlight directement dessous en 1° position
*/
public class GestionLumiere : MonoBehaviour {
private Light jourNuit;
public GameObject[] listSpotLight;
void Start () {
jourNuit = GameObject.Find ("Sky Dome").transform.FindChild ("Light").GetComponent<Light>();
listSpotLight = new GameObject[this.transform.childCount];
for (int i = 0; i < this.transform.childCount; i++) {
listSpotLight[i] = this.transform.GetChild(i).GetChild(0).gameObject;
}
}
void Update () {
if (jourNuit.intensity < 0.15f){
ChangeEtatFeux (true);
} else {
ChangeEtatFeux (false);
}
}
void ChangeEtatFeux (bool allumer) {
for (int i = 0; i < this.transform.childCount; i++) {
listSpotLight[i].SetActive(allumer);
}
}
}