0
0
Unityframework~10 mins

Scene creation and management in Unity - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Scene creation and management
Start Unity Editor
Create New Scene
Add GameObjects
Save Scene with Name
Load Scene by Name
Manage Scene (Additive, Unload)
Play and Test Scene
Modify and Save Changes
Exit or Load Another Scene
This flow shows how you create, save, load, and manage scenes step-by-step in Unity.
Execution Sample
Unity
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour {
    public void LoadGameScene() {
        SceneManager.LoadScene("GameScene");
    }
}
This code loads a scene named "GameScene" when the function is called.
Execution Table
StepActionSceneManager MethodScene StateOutput/Result
1Start Unity EditorN/ANo scene loadedEditor ready
2Create new sceneN/ANew empty scene createdScene created
3Add GameObjectsN/AScene has objectsObjects visible in scene
4Save scene as 'MainMenu'N/AScene saved with name 'MainMenu'Scene saved
5Call LoadScene('GameScene')SceneManager.LoadScene("GameScene")Unload 'MainMenu', load 'GameScene'GameScene loaded and active
6Additively load 'HUD' sceneSceneManager.LoadScene("HUD", LoadSceneMode.Additive)'GameScene' + 'HUD' loadedBoth scenes active
7Unload 'HUD' sceneSceneManager.UnloadSceneAsync("HUD")'HUD' unloaded, 'GameScene' activeHUD removed
8Exit play modeN/AReturn to editor sceneBack to editor
9EndN/AExecution completeNo further action
💡 Execution stops after scenes are loaded/unloaded and play mode ends.
Variable Tracker
VariableStartAfter Step 4After Step 5After Step 6After Step 7Final
CurrentSceneNoneMainMenuGameSceneGameScene + HUDGameSceneGameScene
IsAdditiveLoadFalseFalseFalseTrueFalseFalse
Key Moments - 3 Insights
Why does loading a scene replace the current scene by default?
By default, SceneManager.LoadScene unloads the current scene and loads the new one, as shown in step 5 of the execution_table. To keep multiple scenes, you must use additive loading.
What happens when you load a scene additively?
Additive loading adds the new scene to the currently loaded scenes without unloading them, as seen in step 6 where 'HUD' is added alongside 'GameScene'.
How do you unload a scene that was loaded additively?
You use SceneManager.UnloadSceneAsync with the scene name, as in step 7 where 'HUD' is unloaded, removing it from active scenes.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 5. What scene is active after LoadScene("GameScene") is called?
A"MainMenu"
B"HUD"
C"GameScene"
DNo scene is active
💡 Hint
Check the 'Scene State' column at step 5 in the execution_table.
At which step does the scene manager have two scenes loaded at once?
AStep 5
BStep 6
CStep 4
DStep 7
💡 Hint
Look for 'GameScene + HUD' in the 'Scene State' column in the execution_table.
If you want to keep the current scene and add a new one, which SceneManager method and mode should you use?
ALoadScene with LoadSceneMode.Additive
BLoadScene with LoadSceneMode.Single
CUnloadSceneAsync
DLoadSceneAsync with LoadSceneMode.Single
💡 Hint
Refer to step 6 in the execution_table where additive loading is used.
Concept Snapshot
Scene creation and management in Unity:
- Create scenes in Editor, add GameObjects
- Save scenes with unique names
- Load scenes with SceneManager.LoadScene(name)
- Default load unloads current scene
- Use LoadSceneMode.Additive to load multiple scenes
- Unload scenes with SceneManager.UnloadSceneAsync(name)
Full Transcript
This lesson shows how to create and manage scenes in Unity. You start by creating a new scene in the editor and adding game objects. Then you save the scene with a name like 'MainMenu'. To switch scenes in code, you call SceneManager.LoadScene with the scene name. By default, this unloads the current scene and loads the new one. If you want to load multiple scenes at once, use LoadScene with LoadSceneMode.Additive. You can unload additive scenes with UnloadSceneAsync. The execution table traces these steps showing scene states and method calls. The variable tracker shows how the current scene changes over time. Key moments explain why additive loading is needed and how unloading works. The quiz tests your understanding of scene states and loading modes. Remember, managing scenes well helps organize your game and control what the player sees.