- Home /
Coroutine execution not continuing [Solved]
I set up a very simple coroutine which pauses at the first yield return null
, but it never gets going again.
void Start() {
// Other stuff
StartCoroutine(RefreshAreas());
}
IEnumerator RefreshAreas() {
Debug.Log("RefreshAreas() started."); // I see this in the console
yield return null;
Debug.Log("RefreshAreas() continued."); // This never happens
}
I do have the object set to start early in the script execution order, but I didn't think this would change anything. I've also tried yield return new WaitForEndOfFrame()
and yield return new WaitForSeconds(1.0)
and the second log message still never appears in the console.
What am I doing wrong, how do I get the rest of the function to execute?
I figured out why. The behaviour was deactivated then reactivated. I have to start the coroutine again after it is reactivated.
You may use OnActivate() ins$$anonymous$$d of Start()
Answer by giulio-pierucci · Mar 02, 2015 at 08:25 PM
The script is correct.
Maybe that other stuff destroy the gameobject? Coroutines ends when gameobject dies.