WaitForSeconds 等待秒数
Inherits from YieldInstruction
Suspends the coroutine execution for the given amount of seconds.
在给定的秒数内,暂停协同程序的执行。
WaitForSeconds can only be used with a yield statement in coroutines.
在coroutine中WaitForFixedUpdate只能用于yield声明。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public IEnumerator Awake() {
print(Time.time);
yield return new WaitForSeconds(5);
print(Time.time);
}
}
// Prints 0
print (Time.time);
// Waits 5 seconds 等待5秒
yield WaitForSeconds (5);
// Prints 5.0
print (Time.time);
Constructors构造器
-
Creates a yield instruction to wait for a given number of seconds
最后修改:2010年12月25日 Saturday 16:20