protected virtual void Update() { List <string> coroutines = new List <string>(coroutinesTable.Keys); foreach (string coroutine in coroutines) { MyCoroutine myCoroutine = coroutinesTable[coroutine]; if (myCoroutine == null || myCoroutine.coroutineBodyStack == null || myCoroutine.coroutineBodyStack.Count <= 0) { coroutinesTable.Remove(coroutine); continue; } IEnumerator it = myCoroutine.coroutineBodyStack.Peek(); if (it.MoveNext()) { if (it.Current is IEnumerator) { myCoroutine.coroutineBodyStack.Push(it.Current as IEnumerator); } else { if (myCoroutine.updateCallback != null) { myCoroutine.updateCallback(it.Current); } } } else { myCoroutine.coroutineBodyStack.Pop(); if (myCoroutine.coroutineBodyStack.Count <= 0) { coroutinesTable.Remove(coroutine); if (myCoroutine.finishCallback != null) { myCoroutine.finishCallback(myCoroutine.finishCallbackParam); } } } } Repaint(); }