Bake data in multiple scenes
Use scripts to edit multiple scenes
You can edit multiple scenesA 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 using scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary within the Editor or at runtime.
Use scripts within the Editor
When using (or running) scripts within the Editor, use:
-
Scene struct: Available both in the Editor and at runtime, Scene struct contains read-only properties that relate to the scene itself, such as name and asset path.
-
EditorSceneManager API: This class is only available only in the Editor and has several functions to implement all the Multi-Scene editing features described in the pages Setup multiple scenes and Bake data in multiple scenes.
- SceneSetup utility class: A utility class that you can use to store information about a scene that is in the Hierarchy window.
Use runtime scripts
When using scripts at runtime to edit multiple scenes, use the functions in the SceneManager class such as LoadScene
and UnloadScene
.
Tips:
- To instantiate a prefabAn asset type that allows you to store a GameObject complete with components and properties. The prefab acts as a template from which you can create new object instances in the scene. More info
See in Glossary in a scene, use PrefabUtility.InstantiatePrefab.
- To move objects to the root of a scene, use Undo.MoveGameObjectToScene.
- To avoid having to setup your Hierarchy window every time you restart the Editor, or to store different setups, use EditorSceneManager.GetSceneManagerSetup, which also gets a list of SceneSetup objects that describes the current setup. You can serialize the objects into a
ScriptableObject
along with any other information you want to store about your scene setup. To restore your Hierarchy window, recreate the list of SceneSetups
and use EditorSceneManager.RestoreSceneManagerSetup.
- To get a list of your loaded scenes at runtime, get the
sceneCount
and iterate over the scenes with GetSceneAt
.
Bake data in multiple scenes