StartCoroutine yield[unity2d]

时间:2020-05-08 发布者: 访问量:3904

使用yield语句可以暂停(pause)协同程序的执行,yield的返回值指定在什么时候继续(resume)协同程序。

yield return null; //暂停协同程序,下一帧再继续往下执行
yield new WaitForFixedUpdate (); //暂停协同程序,等到下一次调用FixedUpdate方法时再继续往下执行
yield return new WaitForSeconds(2);//暂停协同程序,2秒之后再继续往下执行
yield return StartCoroutine("SomeCortoutineMethod");//暂停此协同程序,开启SomeCortoutineMethod协同程序,直到SomeCortoutineMethod执行完再继续往下执行
发布于
  用户评论
    生活编程