<span style="font-size:14px;">using UnityEngine;
using System.Collections;
//Unity延迟调用
public class Test : MonoBehaviour {
void Start()
{
// IEnumerator 方法必须使用如下方法进行调用
StartCoroutine("DelayDebug", 3.0f);
StartCoroutine(DelayDebug( 3.0f));
}
IEnumerator DelayDebug( float time)
{
//调用该方法,立即执行return前的代码
Debug.Log("first");
//延迟 time 秒执行return 后边的语句
yield return new WaitForSeconds( time);
Debug.Log("Debug");
}
}</span>
Unity延迟调用
最新推荐文章于 2024-05-09 11:10:22 发布