public abstract class AssetCreator : ScriptableObject
Base abstract class for Asset Creators. The main intention behind the Asset Creator
is to allow you to add
new chunk/chunk assets to your project while using the World Designer tool. Whenever
the tool needs a new chunk/chunk asset
for a cell, it request the Asset Creator assigned to the current World Grouping being
edited to create the asset.
Note this is an abstract class and has no implementation. You must either use the
Default Asset Creator or create
an asset creator yourself that implements some logic that creates the asset. Typically
each Asset Creator is associated with a specific
folder where the assets are created, and you should create different Asset Creators
assets in order to handle the creation of assets that need
to be stored in differentn folders. The caveat to that is if you are creating multiple
assets per call of Create Asset.
For instance, the Default Asset Creator is capable of creating a prefab asset and
a scene asset for each call of Create Asset, and each
may be stored in separate folders using a single Asset Creator asset.
The use of this class offers unlimited implemntation freedom. For instance, you could
implement an Asset Creator that writes data about the
new asset to a file, rather than actually creating a new asset in the project.
public abstract void CreateAssetsForCellChunk(ChunkInfo chunkInfo)
Abstract CreateAssetsForCellChunk Method. The expectation is that you will create at least one asset when this method is called, however in reality you can choose to create multiple assets (of different types; for instance a prefab asset and a scene asset), or you can just store information in a file rather than creating a new asset.
Name | Type | Description |
---|---|---|
chunkInfo | ChunkInfo |
Info related to the chunk that the assets are needed for.
|
public virtual void BatchEditingStopped()
This method is called just after batch editing ends (however, it is only called when CanUseWithBatchAssetEditing returns true for an LOD).
You can override it to implement logic to perform cleanup and to execute pending actions
for the batch Asset Creation calls.
For example,
the default asset creator (when not using a prefab template with a terrain) can be
used with batch editing.
When batch editing is used, newly generated scenes are not added to the build settings
immediately.
Instead, they are added to an internal list and once the batch editing is finished
and this method is called,
they are added to the Build Settings.
public abstract bool CanUseWithBatchAssetEditing(int LOD)
Override to return a value indicating whether the Asset Creator can be used with batch
asset editing for the given LOD. Batch asset editing utilizes
AssetDatabase.StartAssetEditing and AssetDatabase.StopAssetEditing before and after
a batch of CreateAssetsForCellChunk calls for a given LOD. This speeds up
editor performance, however introduces some limitations, namely that assets created
via the AssetCreator are not immediately available (they
only become available after the last CreateAssetsForCellChunk in the batch is called
and StopAssetEditing is called).
The Default Asset Creator can always be used with batch editing.
If batch editing can be used, it is always used, regardless of the number of asset
chunks that need assets created.
Name | Type | Description |
---|---|---|
LOD | int |
The LOD that the next batch of CreateAssetsForCellChunk calls will be used for. Batches are always guarnateed to make use of the same LOD. |
bool
Return true in your override if the Asset Creator can be used with batch editing for
the given LOD. If not, return false.
public virtual void StartingBatchEditing()
If you override CanUseWithBatchAssetEditing to return true for at least one LOD, this
method will be called when creating asset chunks for that LOD.
Overriding it is optional, however typically there will be some setup required when
performing batch editing.
For example, the default asset creator (when not using a prefab template with a terrain)
can be used with batch editing.
When batch editing is used, newly generated scenes are not added to the build settings
immediately.
Instead, they are added to an internal list and once the batch editing is finished,
they are added to the Build Settings (when BatchEditingStopped is called).
This method is used to store the current Editor Building Setting scenes (before the
new ones are added).