一、协程
void Start()
{
StartCoroutine(delay());
}
IEnumerator delay()
{
yield return new WaitForSeconds(0.5f);
//0.5秒后执行
}
二、Invoke 和 InvokeRepeating
void Start()
{
Invoke("TestFunc", 5f);
InvokeRepeating("TestFunc1", 1, 5);
}
void TestFunc()
{
Debug.Log(5);
}
void TestFunc1()
{
Debug.Log("一秒后执行,之后五秒执行一次");
}
三、 VP_Timer 实现定时器(插件)
vp_Timer
一共有3个class,都各司其职:vp_Timer,Event