0
0
Unityframework~20 mins

Scene creation and management in Unity - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Scene Mastery
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 Unity C# code when loading a scene?

Consider the following Unity C# script snippet that loads a scene asynchronously:

using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour {
    void Start() {
        SceneManager.LoadSceneAsync("Level2");
        Debug.Log("Scene loading started");
    }
}

What will be printed in the Unity Console when this script runs?

Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour {
    void Start() {
        SceneManager.LoadSceneAsync("Level2");
        Debug.Log("Scene loading started");
    }
}
ANo output because LoadSceneAsync is asynchronous
BScene loading started\nLevel2 scene loaded
CScene loading started
DError: Scene 'Level2' not found
Attempts:
2 left
💡 Hint

Remember that LoadSceneAsync starts loading but does not block the thread.

🧠 Conceptual
intermediate
1:30remaining
Which Unity method is used to add a scene to the current scenes without unloading others?

In Unity, you want to load a new scene but keep the current scene active and loaded. Which method should you use?

ASceneManager.LoadScene("NewScene", LoadSceneMode.Additive)
BSceneManager.LoadScene("NewScene")
CSceneManager.UnloadSceneAsync("CurrentScene")
DSceneManager.LoadSceneAsync("NewScene", LoadSceneMode.Single)
Attempts:
2 left
💡 Hint

Think about how to keep multiple scenes loaded at once.

🔧 Debug
advanced
2:30remaining
Why does this Unity code fail to unload a scene?

Examine the following code snippet:

using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneUnloader : MonoBehaviour {
    void Start() {
        SceneManager.UnloadSceneAsync("Level1");
        Debug.Log("Unload requested");
    }
}

After running, the scene "Level1" remains loaded. What is the most likely reason?

Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneUnloader : MonoBehaviour {
    void Start() {
        SceneManager.UnloadSceneAsync("Level1");
        Debug.Log("Unload requested");
    }
}
AUnloadSceneAsync requires a scene index, not a name
BUnloadSceneAsync only works in the editor, not in builds
CUnloadSceneAsync is synchronous and blocks until unload completes
DThe scene "Level1" is the active scene and cannot be unloaded until another scene is active
Attempts:
2 left
💡 Hint

Think about Unity's rules for unloading active scenes.

📝 Syntax
advanced
2:30remaining
Which code snippet correctly loads a scene and executes code after loading completes?

You want to load a scene asynchronously and then print "Scene loaded" only after the scene finishes loading. Which code snippet is correct?

A
SceneManager.LoadScene("Level3");
Debug.Log("Scene loaded");
B
var asyncOp = SceneManager.LoadSceneAsync("Level3");
asyncOp.completed += (op) => Debug.Log("Scene loaded");
C
SceneManager.LoadSceneAsync("Level3");
Debug.Log("Scene loaded");
D
var asyncOp = SceneManager.LoadSceneAsync("Level3");
asyncOp.isDone = true;
Debug.Log("Scene loaded");
Attempts:
2 left
💡 Hint

Look for how to detect completion of asynchronous loading.

🚀 Application
expert
3:00remaining
How many scenes are loaded after this code runs?

Given the following Unity C# code executed in a project with three scenes: "MainMenu", "Level1", and "Level2". Initially, only "MainMenu" is loaded and active.

using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneTest : MonoBehaviour {
    void Start() {
        SceneManager.LoadScene("Level1", LoadSceneMode.Additive);
        SceneManager.LoadSceneAsync("Level2", LoadSceneMode.Additive);
        SceneManager.UnloadSceneAsync("MainMenu");
    }
}

After all operations complete, how many scenes remain loaded?

Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneTest : MonoBehaviour {
    void Start() {
        SceneManager.LoadScene("Level1", LoadSceneMode.Additive);
        SceneManager.LoadSceneAsync("Level2", LoadSceneMode.Additive);
        SceneManager.UnloadSceneAsync("MainMenu");
    }
}
A3 scenes: MainMenu, Level1, and Level2
B2 scenes: Level1 and Level2
C1 scene: Level2 only
D2 scenes: MainMenu and Level1
Attempts:
2 left
💡 Hint

Consider the effect of additive loading and unloading asynchronously.