unity, 延迟执行代码

使用协程实现比较方便,可以带参数。

void Start(){

  StartCoroutine(delayLaunchRocket(rocket,2.0f));

}

 


IEnumerator delayLaunchRocket(Obj rocket,float delayTime){

  yield return new WaitForSeconds (delayTime);

  rocket.launch();

}

你可能感兴趣的:(unity)