Version: 2021.3

WaitForSecondsRealtime

class in UnityEngine

/

继承自:CustomYieldInstruction

切换到手册

描述

使用未缩放时间将协同程序执行暂停指定的秒数。

如果要使用缩放时间进行等待,请参阅 WaitForSeconds。\ 在协程中,WaitForSecondsRealtime 只能与 yield 语句结合使用。

using UnityEngine;
using System.Collections;

public class WaitForSecondsExample : MonoBehaviour { void Start() { StartCoroutine(Example()); }

IEnumerator Example() { print(Time.time); yield return new WaitForSecondsRealtime(5); print(Time.time); } }

变量

waitTimeyield 指令等待的给定秒数。

构造函数

WaitForSecondsRealtime创建一个 yield 指令,以使用未缩放时间等待指定的秒数。

继承的成员

变量

keepWaiting指示协同程序是否应保持暂停。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961