static void EditorUpdate() { if (ieList.Count <= 0) { return; } if (!isTicking) { return; } for (int i = 0; i < ieList.Count; i++) { bool moveNext = true; if (ieList[i].Current != null) { //查看是否只自定义的wait事件 //我并不清楚,unity源码中是怎么做的,所以没有什么办法兼容。。。 Type type = ieList[i].Current.GetType(); if (type == typeof(WaitForSomeFrame) || type == typeof(WaitForSomeTime)) { IWait wait = (IWait)ieList[i].Current; if (wait.isDone()) { moveNext = ieList[i].MoveNext(); } } else { moveNext = ieList[i].MoveNext(); } } else { moveNext = ieList[i].MoveNext(); } if (!moveNext) { removeList.Add(i); if (actionList.Count > i && actionList[i] != null) { actionList[i].Invoke(); } } } //是否有需要删除的元素 if (removeList.Count <= 0) { return; } removeList.Reverse(); for (int i = 0; i < removeList.Count; i++) { ieList.RemoveAt(removeList[i]); actionList.RemoveAt(removeList[i]); } removeList.Clear(); if (ieList.Count <= 0) { EditorApplication.update -= EditorUpdate; isTicking = false; Debug.Log("coroutine stop"); } }