IEnumerator Start() { Debug.Log("协程开始"); yield return new WaitForSeconds(2f); Debug.Log("等待了2秒后继续执行"); yield return new WaitForSeconds(1f); Debug.Log("又等待了1秒后继续执行"); }
IEnumerator MyCoroutineA() { Debug.Log("协程 A 开始执行"); yield return StartCoroutine(MyCoroutineB()); Debug.Log("协程 A 继续执行"); } IEnumerator MyCoroutineB() { Debug.Log("协程 B 开始执行"); yield return new WaitForSeconds(2f); Debug.Log("协程 B 完成执行"); }
IEnumerator MyCoroutine() { Debug.Log("协程开始执行"); yield return null; // 让出主线程 Debug.Log("协程在下一帧继续执行"); }
标签:return,Log,yield,Unity,Debug,协程,IEnumerator From: https://www.cnblogs.com/XieBoss-blogs1/p/18237547