用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:waitforseconds:waitforseconds

WaitForSeconds 等待几秒

Namespace: UnityEngine

Inherits from: YieldInstruction

Description 描述

Suspends the coroutine execution for the given amount of seconds.

在给定的秒数内,暂停协同程序的执行。

WaitForSeconds can only be used with a yield statement in coroutines.

WaitForSeconds只能用在协同程序中的yield声明。

JavaScript:

// Prints 0
print (Time.time);
// Waits 5 seconds
yield WaitForSeconds (5);
// Prints 5.0
print (Time.time);

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    IEnumerator Example() {
        print(Time.time);
        yield return new WaitForSeconds(5);
        print(Time.time);
    }
}

Constructors 构造器

WaitForSeconds Creates a yield instruction to wait for a given number of seconds.
创建一个yield指令,来等待给定的秒数。
script/unityengine/classes/waitforseconds/waitforseconds.txt · 最后更改: 2016/08/02 05:25 (外部编辑)