标签:span resume har 使用方法 post uitable int happy suitable
A coroutine is a function that is executed partially and, presuming suitable conditions are met, will be resumed at some point in the future until its work is done
.协程是一个分部运行。遇到条件(yield return 语句)会挂起。直到条件满足才会被唤醒继续运行后面的代码。
<span style="font-family:SimSun;">IEnumerator Fun() { yield returnnewWaitForSeconds(5.0F); //do something }</span>
b>等待其它事件完毕
<span style="font-family:SimSun;">IEnumerator Do() { print("1"); yield returnnewWaitForSeconds(2); print("2"); } IEnumerator Fun() { print("3") yield returnStartCoroutine(Do()); print("4"); }</span>
<span style="font-family:SimSun;">IEnumerator Do() { print("1"); yield return new WaitForSeconds(2); print("2"); } void Fun() { print("3"); StartCoroutine(Do()); print("4"); }</span>
<span style="font-family:SimSun;">Ienumerator Do() { while(true) { print("happy"); yield return null;//等待这一帧结束 //yield return new WaitForFixedUpdate(); //等待全部脚本的fixedupdate运行完成 //yield return new WaitForEndOfFrame(); } }</span>
<span style="font-family:SimSun;">yield return new WWWContinue()</span>f>yield break
标签:span resume har 使用方法 post uitable int happy suitable
原文地址:http://www.cnblogs.com/mthoutai/p/7183434.html