Give Page Feedback

Scriptable Assets - Scene Formatter

The Scene Formatter has been designed to allow you to place a batch of scenes in this correct format in an easy and intuitive way. Prior to update 1.5.0, this functionality was found in the Scene Formatter window, however it is not found in dedicated Scene Formatter assets.

When using Scenes with the Streamable Assets Manager, the Scene Chunk Streamer and Addressable Scene Streamer both require scenes to be in a specific format, which is as follows:

1) Scenes must contain only one root game object.

2) That root game object must be in a state that matches the Root State setting for whatever LOD Group is using the scene (this setting is found on the Streamable Grid/LOD Group tab).

The root game object can have any number of children, grandchildren, etc. What is important is that it is the only root level game object in the scene. You should be able to tell if this is the case because when you minimize this game object's hierarchy, it should be the only game object visible in your Scene Hierarchy.

Restriction 1 is necessary to ensure a single object can be associated with each scene Asset Chunk. If the scene had more than one root game object, we would need to store each of those references which would complicate things considerably.

Restriction 2 ensures that SAM is can preserve the correct state when loading, editing, and saving the scenes using the World Designer Tool. Do note, however, that in general it is best to use a Deactivated Root State when using scenes. Why, you ask? Due to a restriction in the way Unity works, it is only possible to change the position of scene objects after the scene has been loaded. When the objects are saved in the scene in an activated state, they may appear in the wrong location (for a few short frames at least)! Because of this, we generally only recommend using an Activated Root state if you need access to Build Time Static Batching.

Creating A Scene Formatter Asset

You can create this asset by selecting from the Top Menu Bar:

Assets -> Create -> Deep Space Labs -> SAM -> Scene Formatter

Creating A Scene Formatter From The Top Menu Bar GIF

or by right clicking a folder (or inside a folder) within the Project Hierarchy and selecting from the pop up menu:

Create -> Deep Space Labs -> SAM -> Scene Formatter

Creating A Scene Formatter From Right Click GIF

By default this Asset is given the name SceneFormatter, however we recommend changing this name to something that will better help you differentiate it with other Scene Formatter Assets in the future.

Build Time (Editor) Static Batching

Even though we recommend keeping the root scene object in a deactivated state, one issue with this strategy is that it will break Build Time Static Batching, which is Unity's process of batching together meshes when building the player and entering Play Mode.

There are two ways to get around this. The first is to forego the use of Build Time Static Batching and to use Runtime Static Batching instead, which can be achieved using our Static Batcher Listener component.

The second option is to keep the root objects in the scenes active by disabling the Scene Formatter's Deactivate Roots setting. This should only be used if you are 100% certain your World is fixed (i.e., does not need origin shifting) and configured so that the Asset Chunks contained in the scenes will be loaded at their inherent positions (the position you see when opening the scene and clicking on the Root Object). There are additional issues when using this option, which are covered in the Static Batching Section of the Docs (that Section also goes over Runtime Static Batching in detail).

Also keep in mind, in order to avoid the World Designer Tool resetting the state of these objects to deactive, you must configure the LOD Group (on your Streamable Grid) associated with the scene Asset Chunks so that the Root State setting is set to Activated.

Formatter Efficiency

While you can open and edit your scenes individually in order to place them in the correct format described above, the Scene Formatter Tool allows you to easily format hundreds of scenes in no time. The only restriction is that the scenes must exist in the same folder. If you have scenes in several different folders, you will need to run the Formatter separately for each folder.

Watch Out!

The Scene Formatter processes EVERY scene in the specified folder. If you have a mix of scenes you want formatted and scenes you do not want formatted, you must move the scenes you don't want formatted out of the specified folder before pressing the Format Scenes button!

The same is true for sub folders if you have the Include Sub Folders option enabled, so please be careful!