Creating, loading, and saving Scenes
This page explains how to create, load, and save scenes A Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary .
Creating a new scene
There are several ways to create a new scene:
- Use the New Scene dialog to create a new scene from a specific scene template.
- Use the menu or the Project window A window that shows the contents of your Assets folder (Project tab) More info
See in Glossary to create new scenes from your Project’s Basic scene template without opening the New Scene dialog. - Create a scene from a specific template directly from a C# script.
Unity creates every new scene from a scene template. For information about creating and managing scene templates, see Scene templates.
Creating a new scene from the New Scene dialog
Use the New Scene dialog to create new scenes from specific scene templates in your Project. You can also use the New Scene dialog to find and manage scene templates. For details see The New Scene dialog.
By default, the New Scene dialog opens when you create a new scene from the menu (File > New Scene) or by using a shortcut (Ctrl/Cmd + n).
To create a new Scene:
- Select a template from the list.
- If you want Unity to load the new scene additively (see note below), enable Load Additively.
- Click Create to create a new scene from the template.
If the template does not have any cloneable dependencies, Unity loads the new scene in memory, but does not save it.
If the template has cloneable dependencies, Unity prompts you to choose a location in the Project to save it to. When you save the scene, Unity creates a folder in the same location, and with the same name as the new scene. It then clones the cloneable dependencies into the new folder, and updates the new scene to use the cloned assets instead of the original assets used by the template scene.
Creating a new scene from the menu:
Use the menu (Assets > Create > Scene) to create a new scene without opening the New Scene dialog.
When you create a new scene from the menu, Unity automatically copies the project’s Basic template, and adds the new scene to whichever folder is currently open in the project window.
Creating a new scene from the project window
Use the context menu in the Project window to create a new scene without opening the New Scene dialog.
- Navigate to the folder where you want to create the new scene.
- Right click the folder in the left-hand pane, or right-click an empty area in the right hand pane, and select Create > Scene from the context menu.
When you create a new scene from the menu, Unity automatically copies the project’s Basic template, and adds the new scene to the selected folder.
Creating a new scene from a C# script
To create a new scene from a C# script using a specific scene template, use the Instantiate method.
The Instantiate method instantiates a new scene from a scene template. It returns the newly created Scene handle, and its matching SceneAsset . You can create this scene additively. If the scene contains assets that need to be cloned, you must provide a path for Unity to save the scene to disk.
New scene events
When you create a new scene from a template, either from a script or using the New Scene dialog, Unity triggers an event. Unity triggers this event after the template is instantiated, and also after it triggers the EditorSceneManager.newSceneCreated or EditorSceneManager.sceneOpened events.
Loading scenes
To open a scene, do one of the following:
- In the Project window, double-click the scene asset.
- From the menu, select File > New Scene
- From the menu, select File > Recent Scenes > [NAME-OF-SCENE]
If your current scene contains unsaved changes, Unity prompts you to save the scene or discard the changes.
Opening multiple scenes at once
You can open multiple scenes for editing at the same time. For details, see Multi-Scene editing.
Saving scenes
To save the scene you’re currently working on, choose File > Save Scene from the menu, or press Ctrl + S (Windows) or Cmd + S (macOS).
Saved scene assets visible in the Project window
Загрузить текущую сцену Unity
Пишет, что метод групп не может преобразовать в строку.
В старых версиях вроде как можно было
Но это устаревший код. Как сейчас перезапустить сцену с начала или просто получить её номер?
По идее GetActiveScene — это метод. А вы обращаетесь к нему как к свойству. То есть, минимум, нужно писать так: SceneManager.GetActiveScene() . Это как вступление-отступление.
Далее. Метод GetActiveScene возвращает объект типа Scene у которого, как можно увидеть пройдя по ссылке в документацию, есть поле name, которое возвращает имя сцены.
Соответственно, зная это, вам нужно написать так:
![]()
Дизайн сайта / логотип © 2023 Stack Exchange Inc; пользовательские материалы лицензированы в соответствии с CC BY-SA . rev 2023.3.11.43304
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
Unity Scene Manager Made Simple: A Beginner’s Guide
Scenes are part of every game. Changing scene based on the game’s story or based on the menu is a common functionality required in all game engines. In Unity, the Scene Manager does that job. The Unity Scene Manager manages your scenes at runtime. It is a well-equipped class of Unity engine that we can use to effortlessly switch between scenes. We will cover all of its major functionality in this article, and we will also run you through step-by-step guides on how to apply them.

If you want to manage scenes without writing codes the asset below is really useful.
Unity Scene Manager Properties
The scene manager has 2 basic properties:
- sceneCount: Total number of scenes that are currently loaded
- sceneCountInBuildSettings: How many scenes are currently added and active in your Unity Build Settings
These properties can come in handy if you need to keep track of the number of loaded scenes. Here’s an example script that uses the Unity scene manager properties.


You might be wondering, how can there be more than one scene? Well, this is possible, and it’s called Additive loading. You can load a scene on top of another scene, and have them both renderer and run their scripts at the same time. This may be bad for performance, so please keep that in mind when using it.
How to use Scene Manager in Unity.
Loading and unloading scenes can depend on the type of game you are making. We have listed some commonly used methods in Unity Scene Manager.
Get the current scene name in Unity
You can check which scene is currently loaded by using SceneManager.GetActiveScene(); This will return a string with the scene name that is currently active. In the case where there are multiple scenes active, it will return the first scene that was active.

Load scene in Unity
Loading a scene is very simple. You simply need to call the method SceneManager.LoadScene(); and tell it which scene you would like to load. Unity load scene function takes a string as input but it can also be overloaded with a number.

On line 18, I check if I have more than 100 points, if I do, then I load the scene called “Level 2”. It’s that easy. You just need to pass the name of the scene to the Unity Load Scene function. A common mistake that people make is using capital letters. This function is case sensitive so be careful while typing the scene name.
Additive Loading
As mentioned before, you can also load a scene on top of another scene. For this example, let’s say I just completed the game, and want to load a leaderboard. I could do this on the same scene, but if for some reason I need to have the leaderboard on a separate scene, I can simply load it onto my current scene and use it as I normally would. You can also create a leaderboard within the scene similar to creating a pause menu in Unity.
It is very similar to loading a scene normally, except you also add a parameter to specify whether the scene should load additively, or as a single scene. A single scene of course means that there will only be a single scene loaded.
Note: If the LoadSceneMode parameter is not added, the scene will load as Single by default.

SetActiveScene()
You need to specify which is the active scene when using additive loading. In the example below, when the player gets 100 points, the leaderboard scene is set to active.
We are using the GetSceneByName() function to get the scene and loading it using SetActiveScene().

Another important feature is that when you instantiate a prefab in Unity, it will put that object into the currently active scene, so if you have multiple scenes loaded, and you would like to instantiate an object, or delete an object by name, or reference any object, Unity will perform that action based on your current active scene. This method lets you choose which scene is the currently active scene.
How to Load a Scene only Once using PlayerPrefs
Sometimes you need to load a scene only when the player is playing the game for the first time. For example, a tutorial on how to play the game needs to be loaded only once during game start.
What we are going to do
- Save an integer to disk after scene load.
- Check if the integer is equal to one before loading the scene next time.
- If it’s one we load the non-tutorial scene.
- Else load the tutorial scene.
How to reload a scene in Unity
Sometimes it is required to reload a scene when the player fails to complete the task. In Unity, you can get the active scene and load it like any other scene based on the conditions required. As in the example scripts above, you can load the scene either using the scene index or scene name.
The above code also works if you replace the “.name” with “.buildindex”.
How to create a menu in Unity using Scene manager
Unity Scene manager can be used to do a lot of things. The most common example is the main menu. You can switch to a different scene when you press a button on the menu. Let’s see how to create a simple menu using loadscene() function of Scene manager.
The very first step is to create a script. I will be using the same script as the other examples in this tutorial.

Important note: The method must be public, otherwise it cannot be accessed outside the script. This includes buttons as well, so bear that in mind.
Now we have the script setup. Let’s set up the scene and make use of the method we created.
1.Right-click in your hierarchy, and navigate to UI > Button to create a button in your scene (This will automatically create a canvas if you don’t have one). You may use Button, or Button – TextMeshPro. For this example, it does not make any difference. You can name the button whatever you like and can change the text properties to whatever you like as well.

2. Right-click in your hierarchy and select Create Empty. This is where we will put our script that holds the level-changing method

3. Rename the Empty to whatever you like. I will name mine, SceneManager.
4. Attach the script we created in this tutorial to your new SceneManager Empty GameObject you just created. You can do this by selecting Add Component in the inspector and searching for the script by name. In this tutorial my script is called “ExampleScript”, so that’s what I will search for and attach.

5. Select the button game object you created earlier
6. When your button is selected, in the inspector window, find the button component and find the On Click Event section.

7. Click on the + button on the bottom right of the On Click event section to add an event
8. Drag the SceneManager game object into the new event created

9. Click on the No Function drag down menu
10. Navigate to, and select ExampleScript > LoadScene

11. Type in the name of the scene that you want to load when this button is pressed. Make sure that the spelling of the scene is exactly the same as the one in your project. It is also case sensitive, so an even better option is to copy/paste the name from your scene asset into the field.
12. Finally, run the scene and press the button. Your new scene should load!
That’s it, you have successfully created a menu button.
Note: To exit a game in Unity you can use the Application.Quit() method. It doesn’t work in the editor but once the game is built, you can test it on the target platform.
How to Unload a scene in Unity
If you have multiple scenes loaded, you should always unload the scene that you are not using. This will improve your game’s performance, and would also keep your project clean as you are working.
You can Unload a scene by using SceneManager.UnloadSceneAsync(); Async means that it will unload your scene asynchronously. This is good, as it won’t interrupt the game, so you can unload scenes and continue playing/working at the same time.

Similar to the previous examples, I have just added a line at line 24, which means after loading the leaderboards, I unload Level 1 so that I can now only see the leaderboard.
This is pretty similar to simply loading the leaderboard scene as a Single. But by adding these extra steps, you can maybe play some animations, some audio and particles, or whatever it may be in your scene while the leaderboard is up. Then when all your processes on Level 1 are complete, you can unload it.
Unity Scene Manager Events
There are 3 events associated with the Unity Scene Manager, and they can come in handy in a lot of situations:
- SceneManager.activeSceneChanged: This event is triggered whenever the active scene is changed. We have demonstrated this in the previous pages here.
- SceneManager.sceneLoaded: This event is triggered whenever a new scene is loaded. A scene that is loaded is different from active. When a new scene is loaded, the activeSceneChanged event is NOT called. That event is only called when you explicitly decide to set the active scene.
- SceneManager.sceneUnloaded: This event is similar to the sceneLoaded, it is triggered when a scene is Unloaded.
You can use these events by subscribing to them just as you would with any other Unity event. And when a scene is loaded, for example, you can do something in your game. Here’s a code example. In the below code, we subscribe to sceneLoaded and sceneUnloaded to two different functions using the + sign. These functions are called when a scene is loaded or unloaded.

We first need to hook up the Events so that when they get invoked, we can call a method. On lines 16 and 17, we subscribe to the scene manager events. This means that whenever a new scene is loaded, the method OnSceneLoaded will be called. And whenever a scene is Unloaded, the method OnSceneUnloaded will be called.
This is useful if you want to do something specific when a scene is loaded and unloaded, for example, when a scene loads, you may want to initialize some variables to prepare the new level. You could also use this to save your game, too. The possibilities are endless.
If you don’t need to do anything, you do not need to use the events, the scene manager methods work regardless.
Scene Manager does not exit error
If you get the above error, it is mostly because you missed the namespace on the top. Add ” using UnityEngine.SceneManagement” to your script.
If you still get the error then check the spellings in your script. Remember Unity functions are case sensitive.
The ‘S’ and ‘M’ are in capital letters in SceneManager.
As you can see the Unity scene manager is of many uses. You can test out the different functions in different ways. If you need clarification on anything, feel free to leave a comment below.
How to Load a Scene or Exit the Game in Unity
If you are making a game, chances are there are several levels in it, with their own layout and logic so you’ll be organizing your game in different scenes. But how do you navigate between scenes? How do you load a scene at runtime in Unity? Also, how can you exit your game?
Well, it’s really simple just follow the steps to become a Pro at Scene Management in Unity.
Include your Scenes in your Build Settings
In order to navigate between scenes, they need to be added to your Build Settings even when you are play testing in the Editor. Go to File > Build Settings to access these settings.
Your Project’s Build Settings Window
Now that the Build Settings window is open, you can add scenes. You can add the currently opened scenes by clicking the “Add Open Scenes” button or, more useful, you can drag and drop scenes from the explorer to the Build Settings window.
Navigating and quitting the game
Scene Management in Unity is handled by the aptly named SceneManagement module. To access it, you simply need to add “using UnityEngine.SceneManagement;” to your script.
This allows you to call the SceneManager.LoadScene function which has 2 overloads:
- Either pass an integer value, which represents the id of the scene as shown in the Build Settings Window
- Or you can use the name of the Scene as a string.
Quitting is also very straightforward: you only need to call Application.Quit()
Procedurally Generated Levels: Reload the Scene!
If you are using procedurally generated content in your game, where a script instantiates everything when the scene is loaded, you are in luck!
The nice trick is simple: you can reload a currently open scene through the SceneManager. This should clean up the scene and load it anew, as if you were navigating to it for the first time.