WaitForSeconds

class in UnityEngine

/

継承:YieldInstruction

マニュアルに切り替える

説明

スケール化した時間を使用して、指定した秒数の間コルーチンの実行を待ちます。

The actual time suspended is equal to the given time multiplied by Time.timeScale. See WaitForSecondsRealtime if you wish to wait using unscaled time. WaitForSeconds can only be used with a yield statement in coroutines.

There are some factors which can mean the actual amount of time waited does not precisely match the amount of time specified:
1. Start waiting at the end of the current frame. If you start WaitForSeconds with duration 't' in a long frame (for example, one which has a long operation which blocks the main thread such as some synchronous loading), the coroutine will return 't' seconds after the end of the frame, not 't' seconds after it was called.
2. Allow the coroutine to resume on the first frame after 't' seconds has passed, not exactly after 't' seconds has passed.

using UnityEngine;
using System.Collections;

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

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

コンストラクタ

WaitForSecondsスケール化した時間を使用して、指定した秒数の間コルーチンの実行を待ちます。

継承メンバー