Give Page Feedback

Scriptable Assets - Scene Generator

The Scene Generator is a special asset that can aid you in generating Scene Assets from Prefab Assets. Because it has been designed with Unity Editor memory constraints in mind, you can use this tool to batch generate thousands of scenes from prefab assets in a single go, without having to worry about the Unity Editor running out of memory.

Creating A Scene Generator Asset

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

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

Creating A Scene Generator 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 Generator

Creating A Scene Generator From Right Click GIF

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

Streamable Grid Support

Many of the settings found on the Scene Generator correspond to settings found on Streamable Grids, and as such, the Scene Generator has a convenient Streamable Grid field. This optional field allows you to plug in an existing Streamable Grid in order to provide the Generator with information it needs so that you don't have to manually input this information twice.

For example, normally you would need to specify the range of Cells to generate Scenes for (Row 1 through Row 4, Column 1 through Column 4, etc.), however when a Streamable Grid is provided the range is automatically pre-set to cover all Cells in the Streamable Grid, and Disabled Cells are automatically ignored (no scenes will be generated for them).

Of course, override options are available if you don't wish to use some of the information from the Streamable Grid! For example, you can override the range of Cells to generate in order to limit which Asset Chunk Prefabs will have scenes generated. In addition, overriding the range will force the tool to treat all Cells in the range as Enabled. This can be useful if you want to keep the Cells Disabled on the Streamable Grid, but still want to generate Scene Assets for the Asset Chunk Prefabs associated with those Disabled Cells. The tool will still skip generating Scenes for Cells that do not have Asset Chunk Prefabs associated with them!

By default, when a Streamable Grid is provided, the Group Name and Naming Convention associated with the chosen LOD is used for both detecting the Asset Chunk Prefabs in the input folder and for creating the names of the generated Scenes. You may override these settings provide alternative Group Names or Naming Conventions.

Explore Streamable Grid Chapter

Editor Memory and the Progress Bar

In order to limit the amount of memory the tool uses, a Max Scenes To Generate Per Batch setting is provided. If set to 0, all Scenes are generated in a single batch. This will result in faster performance of the tool, however there is a risk that for memory intensive assets or operations that involve a large number of assets, the Editor may run out of memory. In these cases, you can set the setting to a value other than 0.

Smaller values will result in less memory being used, as the memory is freed after each batch of Scenes are generated. Larger values will result in faster completion of the generation operation, but will also utilize more memory. It is up to you to decide which value is best, although we recommend starting with a conservative value of 8 or 16 for large memory assets, and a larger value for smaller assets. You can monitor the memory used by the Unity Editor in Task Manager or a similar program, and increase/decrease the value depending on what you see (decrease if memory usage is too high, increase if it is low and you want to speed up the tool).

As part of the scene generation process, the Asset Database needs to be saved periodically. This will save any assets with unsaved changes, so if you have such assets that you do not wish to be saved, you should finish editing them and save your work before using the tool.

The tool displays a Progress Bar while running to keep you up to date on the progress and to also give you a means of cancelling the operation (useful for longer operations). Unfortunately, Unity's internal operations utilize the same progress bar and will compete with the scene generator's progress bar. This will result in the cancel button disappearing and reappearing. If you wish to cancel the operation, simply keep clicking in the area where the Cancel button appears and you should be able to click it after a moment.

Other Settings

The inspector contains tooltips for most of the settings found on the Scene Generator, so we have elected to not show that information here. Please hover your mouse over the settings names that have an asterisk (*) to see this information!