Complete the code to declare an async method in Unity.
public async Task [1]() { await Task.Delay(1000); Debug.Log("Data loaded"); }
The method name should clearly indicate it is asynchronous by ending with 'Async'.
Complete the code to await a delay of 2 seconds inside an async method.
await [1](2000);
In async methods, Task.Delay is used to asynchronously wait without blocking the main thread.
Fix the error in the async method signature to correctly return a Task.
public async [1] LoadSceneAsync() { await SceneManager.LoadSceneAsync("MainScene").completed; }
Async methods that perform asynchronous operations should return Task to allow awaiting.
Fill both blanks to create a dictionary comprehension that maps scene names to their async load tasks if the scene name length is greater than 5.
var loadTasks = scenes .Where(scene => [2] > 5) .ToDictionary(scene => scene, scene => [1]);
We use SceneManager.LoadSceneAsync(scene).completed to load scenes asynchronously and check the length of the scene name with scene.Length.
Fill all three blanks to create a method that asynchronously loads a scene and logs when done.
public async Task [1](string sceneName) { await [2](sceneName).completed; Debug.Log([3] + " loaded"); }
The method is named LoadSceneAsync, it awaits SceneManager.LoadSceneAsync(sceneName).completed, and logs the sceneName when loading is complete.