WaitForSeconds.WaitForSeconds 等待秒数

static function WaitForSeconds (seconds : float) : WaitForSeconds

Description描述

Creates a yield instruction to wait for a given number of seconds

创建一个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);
Page last updated: 2010-12-25