class in UnityEngine
/
Inherits from:YieldInstruction
/
Implemented in:UnityEngine.CoreModule
Suspends a coroutine until an asynchronous operation completes.
WaitForSecondsRealtime
can only be used with a yield
statement in coroutines.
You can yield
until the AsyncOperation
completes, check whether it's done with AsyncOperation.isDone, or check on its progress with AsyncOperation.progress.
Additional resources: SceneManager.LoadSceneAsync, AssetBundle.LoadAssetAsync, Resources.LoadAsync.
using System.Collections; using UnityEngine;
public class ExampleClass : MonoBehaviour { public void Start() { StartCoroutine(Example_AsyncTests()); }
public IEnumerator Example_AsyncTests() { Debug.Log("Start of AsyncLoad Example"); var load = UnityEngine.Resources.LoadAsync(""); yield return load; yield return null; Debug.Log("End of AsyncLoad Example"); } }
Property | Description |
---|---|
allowSceneActivation | Allow Scenes to be activated as soon as it is ready. |
isDone | Has the operation finished? (Read Only) |
priority | Priority lets you tweak in which order async operation calls will be performed. |
progress | What's the operation's progress. (Read Only) |
Event | Description |
---|---|
completed | Event that is invoked upon operation completion. An event handler that is registered in the same frame as the call that creates it will be invoked next frame, even if the operation is able to complete synchronously. If a handler is registered after the operation has completed and has already invoked the complete event, the handler will be called synchronously. |