Hello,
I made a script that makes a list of the childs of an object and then sets them active one at a time using a coroutine. The script is suscribed to an event on another script’s Start function for testing reasons. It worked perfectly yesterday, but today after opening the project again and pressing play, it didn’t work :S could be something to do with the event? or the coroutine?
public class FootPrintManager : MonoBehaviour {
public delegate void FootstepsShot();
public static event FootstepsShot FootstepsEnd;
public float delayTime = 1.0f;
public List<GameObject> footsteps;
void OnEnable(){
AnimController.ShotLight += StartSteps;
}
void OnDisable(){
AnimController.ShotLight -= StartSteps;
}
public void StartSteps(){
foreach(GameObject step in footsteps){
StartCoroutine("Walking");
}
}
void Start () {
footsteps = new List<GameObject>();
foreach(Transform steps in transform){
footsteps.Add(steps.gameObject);
}
}
IEnumerator Walking(){
foreach(GameObject step in footsteps){
yield return new WaitForSeconds(delayTime);
step.SetActive(true);
}
}
}
Thanks!