Coroutine协同执行程序

StartCoroutine(方法)

将复杂的工作分为几帧过多次来执行

IEnumerator go(){
    yield return null;//停止一帧
    yield return new WaitForSeconds(2f);//等待两秒再往下
    yield return new WaitForFixedUpdate();//等待所有物理Update完成后
}

//调用和停止方法
StartCoroutine(go());
StartCoroutine("go");
StopAllCoroutine();
StopCoroutine("go");

首页 我的博客
粤ICP备17103704号