加载中…
个人资料
丘丘雷雷
丘丘雷雷
  • 博客等级:
  • 博客积分:0
  • 博客访问:175
  • 关注人气:0
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

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执行完再继续往下执行

0

阅读 收藏 喜欢 打印举报/Report
后一篇:Time.delta
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有