Version: 2017.3 (switch to 2018.1b)
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



public static method SetActiveScene(scene: SceneManagement.Scene): bool;
public static bool SetActiveScene(SceneManagement.Scene scene);


scene The Scene to be set.


bool Returns false if the Scene is not loaded yet.


Set the Scene to be active.

The active Scene is the Scene which will be used as the target for new GameObjects instantiated by scripts. When you add a Scene additively (see LoadSceneMode.Additive), the first Scene is still kept as the active Scene. Use this to switch the active Scene to the Scene you want as the target.

no example available in JavaScript
//This script allows you to load a second Scene as an Additive Scene if you press the first Button. Even though the second Scene loads, the first Scene remains the active Scene.
//If you press the second Button, it sets the second Scene as the active Scene

//Attach this script to a GameObject //Create 2 Buttons (Create>UI>Button) //Attach the 2 Buttons to your GameObject’s Inspector

using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI;

public class Example : MonoBehaviour { bool m_SceneLoaded; public Button m_YourButton, m_YourOtherButton;

void Awake() { //Outputs the current active Scene to the console Debug.Log("Active Scene : " + SceneManager.GetActiveScene().name);

//Check that this Button exists if (m_YourButton != null) { //Call the LoadScene2Button() function when this Button is clicked m_YourButton.onClick.AddListener(LoadScene2Button); }

if (m_YourOtherButton != null) { m_YourOtherButton.onClick.AddListener(SetActiveSceneButton); } }

//Load the second Scene when this Button is pressed void LoadScene2Button() { //Check that the second Scene hasn't been added yet if (m_SceneLoaded == false) { //Loads the second Scene SceneManager.LoadScene("Scene2", LoadSceneMode.Additive); //Ouputs the name of the current active scene. //Notice it still outputs the name of the first Scene Debug.Log("Active Scene : " + SceneManager.GetActiveScene().name); //The Scene has been loaded, exit this method m_SceneLoaded = true; } }

void SetActiveSceneButton() { //Allow this other Button to be pressed when the other Button has been pressed (Scene 2 is loaded) if (m_SceneLoaded == true) { //Set Scene2 as the active Scene SceneManager.SetActiveScene(SceneManager.GetSceneByName("Scene2")); //Ouput the same of the active Scene //See now that the name is updated Debug.Log("Active Scene : " + SceneManager.GetActiveScene().name); } } }

Did you find this page useful? Please give it a rating: