0
0
Unityframework~20 mins

Scene transitions in Unity - Practice Problems & Coding Challenges

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

public class SceneLoader : MonoBehaviour
{
    IEnumerator Start()
    {
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("Level2");
        while (!asyncLoad.isDone)
        {
            Debug.Log($"Loading progress: {asyncLoad.progress * 100}%");
            yield return null;
        }
        Debug.Log("Scene loaded!");
    }
}
A
Loading progress: 0%
Loading progress: 90%
Loading progress: 90%
Scene loaded!
B
Loading progress: 0%
Loading progress: 0%
Loading progress: 0%
Scene loaded!
C
Loading progress: 0%
Loading progress: 50%
Loading progress: 100%
Scene loaded!
D
Loading progress: 0%
Loading progress: 0.9%
Loading progress: 0.9%
Scene loaded!
Attempts:
2 left
💡 Hint
Remember that asyncLoad.progress goes from 0 to 0.9 before completion.
🧠 Conceptual
intermediate
1:30remaining
Which method correctly unloads a scene in Unity?
You want to unload a scene named "Menu" to free memory. Which method call is correct?
ASceneManager.DeleteScene("Menu");
BSceneManager.LoadScene("Menu", LoadSceneMode.Unload);
CSceneManager.UnloadSceneAsync("Menu");
DSceneManager.RemoveScene("Menu");
Attempts:
2 left
💡 Hint
Look for the official method to unload scenes asynchronously.
🔧 Debug
advanced
2:00remaining
Why does this scene transition cause a freeze?
This code causes the game to freeze when transitioning scenes. What is the main reason?
Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class FreezeOnLoad : MonoBehaviour
{
    void Start()
    {
        SceneManager.LoadScene("GameScene");
        Debug.Log("Scene loaded");
    }
}
AThe Debug.Log statement causes an infinite loop.
BLoadScene is called synchronously on the main thread, blocking until the scene loads.
CThe scene name "GameScene" is misspelled causing an error.
DStart method cannot call SceneManager.LoadScene.
Attempts:
2 left
💡 Hint
Think about how LoadScene works and its effect on the main thread.
📝 Syntax
advanced
2:30remaining
Which code snippet correctly implements a fade transition before loading a scene?
You want to fade out the screen before loading a new scene. Which code snippet is syntactically correct and will work?
A
IEnumerator FadeAndLoad() {
    yield return FadeOut();
    SceneManager.LoadSceneAsync("NextScene");
}
B
void FadeAndLoad() {
    StartCoroutine(FadeOut());
    SceneManager.LoadScene("NextScene");
}
C
IEnumerator FadeAndLoad() {
    StartCoroutine(FadeOut());
    yield return SceneManager.LoadSceneAsync("NextScene");
}
D
IEnumerator FadeAndLoad() {
    yield return StartCoroutine(FadeOut());
    SceneManager.LoadScene("NextScene");
}
Attempts:
2 left
💡 Hint
Remember that to wait for a coroutine, you must yield return it.
🚀 Application
expert
3:00remaining
How to keep an object alive across scene transitions?
You want a music player object to continue playing music without restarting when changing scenes. Which code snippet achieves this?
A
void Awake() {
    DontDestroyOnLoad(gameObject);
}
B
void Start() {
    SceneManager.LoadScene("NextScene");
}
C
void Awake() {
    Destroy(gameObject);
}
D
void OnEnable() {
    SceneManager.UnloadSceneAsync("CurrentScene");
}
Attempts:
2 left
💡 Hint
Look for the Unity method that prevents destruction on scene load.