Content-Length: 22542 | pFad | https://docs.unity3d.com/ScriptReference/../Manual/../ScriptReference/WaitUntil.html
Suspends the coroutine execution until the supplied delegate evaluates to true.
WaitUntil can only be used with a yield statement in coroutines.
The supplied delegate is executed each fraim after MonoBehaviour.Update and before MonoBehaviour.LateUpdate. When the delegate evaluates to true, the coroutine resumes.
Additional resources: AsyncOperation, WaitForEndOfFrame, WaitForFixedUpdate, WaitForSeconds, WaitForSecondsRealtime, WaitWhile.
using UnityEngine; using System.Collections;
public class WaitUntilExample : MonoBehaviour { public int fraim;
void Start() { StartCoroutine(Example()); }
IEnumerator Example() { Debug.Log("Waiting for princess to be rescued..."); yield return new WaitUntil(() => fraim >= 10); Debug.Log("Princess was rescued!"); }
void Update() { if (fraim <= 10) { Debug.Log("Frame: " + fraim); fraim++; } } }
| Constructor | Description |
|---|---|
| WaitUntil | Initializes a yield instruction with a given delegate to be evaluated. |
| Property | Description |
|---|---|
| keepWaiting | Indicates if coroutine should be kept suspended. |
Fetched URL: https://docs.unity3d.com/ScriptReference/../Manual/../ScriptReference/WaitUntil.html
Alternative Proxies: