0
0
Unityframework~20 mins

Scene loading and unloading in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Scene Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
What is the output of this scene loading code?
Consider the following Unity C# code snippet that loads a scene asynchronously. What will be printed in the console when the scene finishes loading?
Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{
    void Start()
    {
        StartCoroutine(LoadYourAsyncScene());
    }

    System.Collections.IEnumerator LoadYourAsyncScene()
    {
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("Level2");

        while (!asyncLoad.isDone)
        {
            yield return null;
        }

        Debug.Log("Scene Loaded");
    }
}
AScene Loaded
BNo output
CError: Scene not found
DScene Loading
Attempts:
2 left
💡 Hint
Look at when Debug.Log is called in relation to the async loading completion.
🧠 Conceptual
intermediate
1:30remaining
Which method unloads a scene in Unity?
You want to remove a scene from memory in Unity during runtime. Which method should you use?
ASceneManager.UnloadSceneAsync("SceneName")
BSceneManager.LoadScene("SceneName")
CSceneManager.ReloadScene("SceneName")
DSceneManager.AddScene("SceneName")
Attempts:
2 left
💡 Hint
Think about the method that removes a scene asynchronously.
🔧 Debug
advanced
2:00remaining
Why does this scene not unload properly?
This code tries to unload a scene but the scene remains loaded. What is the likely cause?
Unity
using UnityEngine.SceneManagement;

void UnloadScene()
{
    SceneManager.UnloadSceneAsync("GameScene");
}
AThe scene name is case sensitive and "GameScene" is incorrect
BUnloadSceneAsync requires a callback to complete unloading
CUnloadSceneAsync only works in editor mode
DThe scene is set as the active scene and cannot be unloaded
Attempts:
2 left
💡 Hint
Check if the active scene can be unloaded.
📝 Syntax
advanced
1:30remaining
Which code correctly loads a scene additively?
You want to load a scene without unloading the current one. Which code snippet is correct?
ASceneManager.LoadSceneAsync("Level3", LoadSceneMode.Single);
BSceneManager.LoadScene("Level3", LoadSceneMode.Additive);
CSceneManager.LoadSceneAdditive("Level3");
DSceneManager.LoadScene("Level3", LoadMode.Additive);
Attempts:
2 left
💡 Hint
Check the correct enum name for additive loading.
🚀 Application
expert
3:00remaining
How to ensure a scene is fully unloaded before loading another?
You want to unload "SceneA" and then load "SceneB" only after unloading completes. Which approach ensures this order?
Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneSwitcher : MonoBehaviour
{
    public void SwitchScenes()
    {
        // Fill in the blanks
    }
}
A
SceneManager.LoadScene("SceneB");
SceneManager.UnloadSceneAsync("SceneA");
B
SceneManager.UnloadSceneAsync("SceneA");
SceneManager.LoadScene("SceneB");
C
StartCoroutine(UnloadThenLoad());

IEnumerator UnloadThenLoad()
{
    yield return SceneManager.UnloadSceneAsync("SceneA");
    SceneManager.LoadScene("SceneB");
}
D
SceneManager.UnloadScene("SceneA");
SceneManager.LoadSceneAsync("SceneB");
Attempts:
2 left
💡 Hint
Think about waiting for the unload operation to finish before loading.