Unity3d StartCoroutine yield
(2012-09-28 16:57:04)
标签:
杂谈 |
StartCoroutine
The execution of a coroutine can be paused at any point using the
yield statement. The yield return value specifies when the
coroutine is resumed. Coroutines are excellent when modelling
behaviour over several frames. Coroutines have virtually no
performance overhead. StartCoroutine function always returns
immediately, however you can yield the result. This will wait until
the coroutine has finished
execution.
使用yield语句可以暂停(pause)协同程序的执行,yield的返回值指定在什么时候继续(resume)协同程序。
保存修改 yield return null; //暂停协同程序,下一帧再继续往下执行
yield new WaitForFixedUpdate (); //暂停协同程序,等到下一次调用FixedUpdate方法时再继续往下执行
yield return new WaitForSeconds(2);//暂停协同程序,2秒之后再继续往下执行
yield return StartCoroutine("SomeCortoutineMethod");//暂停此协同程序,开启SomeCortoutineMethod协同程序,直到SomeCortoutineMethod执行完再继续往下执行
后一篇:Time.delta