Reputation: 159
Currently, I have this process on my OnGUI function:
void OnGUI ()
{
// process here that adds item on list
Counter = list.Count();
}
I have this code that runs a function when Counter value is changed.
private IEnumerator coroutine = null;
private int counter = 0;
private int limit = 5;
public int Counter
{
get{ return this.counter; }
set
{
this.counter = value;
if(this.counter == limit)
{
if(this.coroutine != null){ return; } // already running
this.coroutine = StartProcess();
StartCoroutine(this.coroutine); }
}
}
StartProcess contains this :
StartProcess ()
{
yield return StartCorotuine (Process1);
yield return StartCorotuine (Process2);
}
Everything works smoothly on my first run but on my second run, it seems like my Counter function is no longer running even if my condition is met?
Upvotes: 0
Views: 49
Reputation: 5035
When a coroutine finishes the pointer to it is still valid, it does not reset to null, you get to keep a handler to a dead coroutine, just add =null at the end and you should be fine
Upvotes: 2