Version: 2022.2
言語: 日本語

WaitUntil

class in UnityEngine

/

継承:CustomYieldInstruction

マニュアルに切り替える

説明

指定されたデリゲートが True に判定されるまでコルーチンの実行を中断します。

WaitUntil はコルーチンの Yield ステートメントでのみ使用できます。

供給されたデリゲートはスクリプト MonoBehaviour.Update の後と MonoBehaviour.LateUpdate の前に各フレームを処理します。デリゲートが最後に True と判定するとき、コルーチンはその処理を続行します。

See Also: AsyncOperation, WaitForEndOfFrame, WaitForFixedUpdate, WaitForSeconds, WaitForSecondsRealtime, WaitWhile.

using UnityEngine;
using System.Collections;

public class WaitUntilExample : MonoBehaviour { public int frame;

void Start() { StartCoroutine(Example()); }

IEnumerator Example() { Debug.Log("Waiting for princess to be rescued..."); yield return new WaitUntil(() => frame >= 10); Debug.Log("Princess was rescued!"); }

void Update() { if (frame <= 10) { Debug.Log("Frame: " + frame); frame++; } } }

コンストラクタ

WaitUntil判定される指定されたデリゲートと Yield 命令を初期化します。

継承メンバー

変数

keepWaitingコルーチンを中断させておく必要がある場合、表示します。