Version: 2018.1

WaitWhile

class in UnityEngine

/

継承:CustomYieldInstruction

マニュアルに切り替える

説明

委譲されたデリゲートが false と判断されるまで、コルーチンの実行を中断します。

WaitWhile はコルーチンの yield ステートメントとともにしか使用できません。

委譲されたデリゲートが MonoBehaviour.Update 後と MonoBehaviour.LateUpdate 前に各フレームで実行されます。デリゲートが false と判断されると、そこで、コルーチンが実行を継続します。

using UnityEngine;
using System.Collections;

public class WaitWhileExample : MonoBehaviour { public int frame;

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

IEnumerator Example() { Debug.Log("Waiting for prince/princess to rescue me..."); yield return new WaitWhile(() => frame < 10); Debug.Log("Finally I have been rescued!"); }

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

コンストラクタ

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

継承メンバー

変数

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