/// <summary> /// 执行 /// </summary> /// <returns></returns> private IEnumerator <float> Run() { if (isDone) { yield break; } var tasks = new ReCoroutine[taskDict.Count]; for (int i = 0; i < taskDict.Count; i++) { tasks[i] = taskDict.GetValueAt(i).GetCoroutine(); } ///同时执行所有的任务 yield return(ReCoroutine.WaitForAllCoroutines(tasks)); if (this.actionType == TaskActionType.Sync) { //同步按顺序执行 for (int i = 0; i < syncActionList.Count; i++) { syncActionList[i](); } } else { //异步按顺序执行 for (int i = 0; i < asynActionList.Count; i++) { yield return(ReCoroutine.Wait(asynActionList[i])); } } isDone = true; }
/// <summary> /// 执行 /// </summary> private IEnumerator <float> Run() { var tasks = new ReCoroutine[taskDict.Count]; for (int i = 0; i < taskDict.Count; i++) { //按顺序执行 yield return(ReCoroutine.Wait(taskDict.GetValueAt(i).GetCoroutine())); } }
IEnumerator <float> TestWaitCor() { Debug.Log("BeginWait"); WWW www = new WWW("http://121.196.216.106:4040/Escape/ServerAddress.txt"); yield return(ReCoroutine.WaitWWW(www)); Debug.Log(www.text); Debug.Log("EndWait"); }