Give Page Feedback | API

World Designer Tool - Asset Creators

Asset Creators are responsible for creating new Asset Chunks when the World Designer Tool requires them. Typically, Asset Creators are created with specific LOD Asset Chunk Groups in mind, however it is possible to use the same Asset Creator with multiple LOD Groups in certain scenarios. You can use the Default Asset Creator (included with the Streamable Assets Manager for free), or create a completely custom Asset Creator for fine-tuned control.

Asset Creators are assigned to specific LODs on World Groupings within the World Designer Tool. The asset references are stored in the World Designer Data Asset so that they are not lost between editing sessions (as such, if you delete or change the Data Asset used by a World, the Asset Creator references may be lost).

While it can feel a bit annoying assigning a separate Creator to each LOD, this systems gives you the greatest degree of flexibility possible, as you have full control over how each and every Asset Chunk is created.

The Default Asset Creator

The Default Asset Creator is the only Asset Creator included with the Streamable Assets Manager, and while it is relatively simple in functionality, it should cover a variety of use cases. To learn more about this asset, please navigate to the Default Asset Creator Section within the Scriptable Assets Chapter.

Default Asset Creator

Custom Asset Creators (Script Creation)

In order to create a custom Asset Creator, start by creating a new script with a class that derives from the AssetCreator base abstract class. You should place this class definition inside of the DeepSpaceLabs.EditorSAM namespace in order to use the AssetCreator class, and the script file you create needs to be placed inside a folder called Editor in order for it to see the DeepSpaceLabs.EditorSAM namespace.

--Special Note--
An easy way to start with your custom class is to hover over your custom class name and choose the option Show potential fixes -> Implement abstract class. This will provide default overrides for all abstract class members (4 methods in total).

Custom Asset Creators (CreateAssetsForCellChunk Method)

This is the primary method of the Asset Creator and is the one responsible for creating Asset Chunks. Typically this method will generate only a single asset, however this is not a requirement. You can create as many assets for the Asset Chunk as are needed by your game (Terrain, for example, require an additional TerrainData asset to be created).

The assets created are not returned with this method; instead, you must ensure the LOD that is using the Asset Creator is using an Asset Manager that is able to retrieve the created assets (or if multiple are created, just the ones that are needed for the World Designer tool to work). This also means that you are responsible for placing the Assets correctly within the Project so that they are retrievable by your Asset Manager!

Information about the Asset Chunk you are creating the assets for is included with the ChunkInfo objects that is passed into the method. This information includes the name of the Asset Chunk, the number of the Asset Chunk (remember, each cell can have multiple Asset Chunks associated with it!), the LOD the Asset Chunk belongs to, the initial position of the chunk at the time of creation, as well as the root state of the chunks (only use this if creating scene based Asset Chunks!). We have determined that this is all the info you need at the present time, however if you feel that some other information should be included in the ChunkInfo object, please use the feedback button at the top of this window!

Note that it is up to you whether you want to apply the chunkPosition to the assets you create, however generally speaking it is a good idea to do so.

Custom Asset Creators (Batching)

In order to speed up the performance of multiple Asset Creation operations, the World Designer is able to use the Asset Creator is batch mode if the Asset Creator supports it. To enable batching support, override the CanUseWithBatchAssetEditing method to return true. Return false to disable batching support.

This method is queried every time a set of Asset Chunks are about to be created for a single LOD Group. This allows you to enable batching support for specific LODs while disabling support for others. This can open up use of a single Asset Creator with multiple LODs in some cases, reducing the number of Asset Creators you need to make.

When batching is enabled, the AssetCreator.StartingBatchEditing method is called, immediately followed by a call to AssetDatabase.StartAssetEditing. Next, CreateAssetsForCellChunk is called for each Asset Chunk that needs to be created on the LOD that was passed into CanUseWithBatchAssetEditing. After creating all Asset Chunks, AssetDatabase.StopAssetEditing is called immediately followed by AssetCreator.BatchEditingStopped.

While it can speed up editor performance dramatically, batching does have drawbacks; namely, that any assets created during the batching process are not retrievable until after the batch operation has completed (i.e., after CreateAssetsForCellChunk has been called for all Asset Chunks in the batch). As such, if your Asset Creator needs to access a generated asset immediately in order to process or generate additional assets, you will not be able to utilize batching!

One workaround, however, is to use the AssetCreator.BatchEditingStopped to retrieve those assets and to generate all secondary assets.

You can also use this method to perform secondary operations. For example, the Default Asset Creator uses this method to add a batch of scenes to the Editor Build Settings in one go, rather than adding each one by one with each call to CreateAssetsForCellChunk (which would be much slower).

The AssetCreator.StartingBatchEditing method can be used to prepare for the batching process. For instance, you may wish to use it to record that batching is being used, so that other methods can react accordingly.

Custom Asset Creators (Generating the Asset)

Once you finish creating custom Asset Creator script, you will need to make an editor command to generate new instances of the Scriptable Asset within your project. To do so, create a static method inside some editor class that has the following attribute:

[MenuItem(GlobalValues.ASSET_CREATION_PATH + "Custom Asset Creator Name", false)]

Within this method, you can use the following line of code to create the Scriptable Asset, replacing CustomAssetCreator with the class name of your Custom Asset Creator.

ScriptableObjectAssetCreator.GenerateScriptableObjectAssetAtSelectedFolder("CustomAssetCreator");

ScriptableObjectAssetCreator is a special class found inside the DeepSpaceLabs.EditorCore namespace. You will need to add a using statement or type out the full namespace with the class name when declaring the variable in order to use it.