0
0
Unityframework~10 mins

Loading screens with coroutines in Unity - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start the coroutine for loading the scene.

Unity
StartCoroutine([1]());
Drag options to blanks, or click blank then click option'
ALoadSceneAsync
BLoadScene
CUpdateLoading
DShowLoadingScreen
Attempts:
3 left
💡 Hint
Common Mistakes
Using LoadScene instead of LoadSceneAsync causes the scene to load immediately, blocking the main thread.
Calling ShowLoadingScreen() directly does not start the coroutine.
2fill in blank
medium

Complete the code to check if the asynchronous scene loading is done.

Unity
while (![1].isDone) {
    yield return null;
}
Drag options to blanks, or click blank then click option'
ACoroutine
BasyncOperation
CloadingScreen
DSceneManager
Attempts:
3 left
💡 Hint
Common Mistakes
Checking SceneManager.isDone causes errors because SceneManager has no such property.
Using loadingScreen.isDone is incorrect because loadingScreen is a UI element.
3fill in blank
hard

Fix the error in the coroutine declaration to make it valid.

Unity
private [1] LoadSceneAsync() {
    AsyncOperation asyncOperation = SceneManager.LoadSceneAsync("GameScene");
    while (!asyncOperation.isDone) {
        yield return null;
    }
}
Drag options to blanks, or click blank then click option'
Aasync
Bvoid
CIEnumerator
DTask
Attempts:
3 left
💡 Hint
Common Mistakes
Using void causes a compile error because yield return is not allowed.
Using async keyword is not how Unity coroutines work.
4fill in blank
hard

Fill both blanks to update the loading progress bar correctly.

Unity
loadingBar.value = [1].progress / [2];
Drag options to blanks, or click blank then click option'
AasyncOperation
B1.0f
C0.9f
DloadingBar
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by 1.0f causes the progress bar to max out too early.
Using loadingBar.progress instead of asyncOperation.progress gives wrong values.
5fill in blank
hard

Fill all three blanks to hide the loading screen after the scene is loaded.

Unity
if ([1].isDone) {
    [2].SetActive([3]);
}
Drag options to blanks, or click blank then click option'
AasyncOperation
BloadingScreen
Cfalse
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting loadingScreen active to true keeps the loading screen visible.
Checking a wrong variable instead of asyncOperation.isDone causes logic errors.