CreateScene
Create an empty new Scene at runtime with the given name.
Read time 2 minutesLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine.SceneManagement
- Assembly: UnityEngine.CoreModule
CreateScene(string, CreateSceneParameters)
Create an empty new Scene at runtime with the given name.
public static Scene CreateScene(string sceneName, CreateSceneParameters parameters)
Parameters
The name of the new Scene. It cannot be empty or null, or same as the name of the existing Scenes.
Various parameters used to create the Scene.
Returns
Type | Description |
|---|---|
| Scene | A reference to the new Scene that was created, or an invalid Scene if creation failed. |
Remarks
The new Scene will be opened additively into the hierarchy alongside any existing Scenes that are currently open. The path of the new Scene will be empty. This function is for creating Scenes at runtime. To create a Scene at edit-time (for example, when making an editor script or tool which needs to create Scenes), use EditorSceneManager.NewScene.
Examples
using UnityEngine.SceneManagement;using UnityEngine;public class ExampleClass : MonoBehaviour{ public void Awake() { Scene newScene = SceneManager.CreateScene("My New Scene"); }}
CreateScene(string)
Create an empty new Scene at runtime with the given name.
public static Scene CreateScene(string sceneName)
Parameters
The name of the new Scene. It cannot be empty or null, or same as the name of the existing Scenes.
Returns
Type | Description |
|---|---|
| Scene | A reference to the new Scene that was created, or an invalid Scene if creation failed. |
Remarks
The new Scene will be opened additively into the hierarchy alongside any existing Scenes that are currently open. The path of the new Scene will be empty. This function is for creating Scenes at runtime. To create a Scene at edit-time (for example, when making an editor script or tool which needs to create Scenes), use EditorSceneManager.NewScene.
Examples
using UnityEngine.SceneManagement;using UnityEngine;public class ExampleClass : MonoBehaviour{ public void Awake() { Scene newScene = SceneManager.CreateScene("My New Scene"); }}