Files
Hasebe/Library/PackageCache/com.unity.addressables@42676f2a154e/Documentation~/load-wait-asynchronous-async-await.md
T
2026-09-21 12:15:57 +03:00

1.9 KiB

Wait for asynchronous loads with async and await

AsyncOperationHandle provides a Task object that you can use with the C# async and await keywords to sequence code that calls asynchronous methods and handles the results.

The following example loads Addressable assets using a list of keys. The differences between this task-based approach and the coroutine or event-based approaches are in the signature of the calling method. This method must include the async and await keywords with the operation handle's Task property. The calling method, Start in this case, suspends operation while the task finishes. Execution then resumes and the example instantiates all the loaded prefabs in a grid pattern.

[!code-cssample]

When you use Task-based operation handling, you can use the C# Task class methods such as WhenAll to control which operations you run in parallel and which you want to run in sequence. The following example illustrates how to wait for more than one operation to finish before moving onto the next task:

[!code-cssample]

Additional resources