0
0
Unityframework~10 mins

Scene transitions 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 load a scene named "GameScene" using Unity's SceneManager.

Unity
SceneManager.[1]("GameScene");
Drag options to blanks, or click blank then click option'
ALoadScene
BUnloadScene
CActivateScene
DStartScene
Attempts:
3 left
💡 Hint
Common Mistakes
Using UnloadScene instead of LoadScene.
Trying to use StartScene which does not exist.
2fill in blank
medium

Complete the code to add the UnityEngine.SceneManagement namespace needed for scene transitions.

Unity
using [1];
Drag options to blanks, or click blank then click option'
AUnityEngine.SceneManagement
BUnityEngine.Audio
CUnityEngine.UI
DUnityEngine.Physics
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated namespaces like UI or Audio.
Forgetting to add the namespace and getting errors.
3fill in blank
hard

Fix the error in the code to load a scene asynchronously named "Level1".

Unity
SceneManager.[1]("Level1");
Drag options to blanks, or click blank then click option'
ALoadLevel
BLoadScene
CLoadAsyncScene
DLoadSceneAsync
Attempts:
3 left
💡 Hint
Common Mistakes
Using LoadScene which loads synchronously.
Using non-existent methods like LoadLevel.
4fill in blank
hard

Fill both blanks to check if the current active scene's name is "Menu".

Unity
if (SceneManager.[1]().[2] == "Menu") {
    // do something
}
Drag options to blanks, or click blank then click option'
AGetActiveScene
Bname
CsceneName
DGetSceneByName
Attempts:
3 left
💡 Hint
Common Mistakes
Using GetSceneByName which requires a parameter.
Using sceneName which is not a valid property.
5fill in blank
hard

Fill all three blanks to create a dictionary mapping scene names to their build indexes for scenes with index less than 3.

Unity
var scenes = new Dictionary<string, int> {
    {"[1]", [2]
};

for (int i = 0; i < 5; i++) {
    var scene = SceneManager.GetSceneByBuildIndex(i);
    if (i [3] 3) {
        scenes[scene.name] = i;
    }
}
Drag options to blanks, or click blank then click option'
AIntro
B0
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' in the condition.
Using the variable 'i' instead of the number '0' for the dictionary value.