WorldDesignerGroupingListener Class

public abstract class WorldDesignerGroupingListener : ScriptableObject

A Scriptable Object class you can derive from and hook up to the World Designer tool to receive notifications when Asset Chunks are added and removed from the scene using the Tool.

This is useful if you need to perform some secondary operations on the assets, perhaps involving third party tools.

Do note that this feature has some limitations, including:

1) References to the assets may become nulled out under different situations, such as unloading the scene the assets are in or performing an assembly reload (but not always in this case). This, in combination with item 2 below, may cause issues.

2) Only newly loaded assets are passed to the OnAfterAssetChunksAdded method. You will need to account for this and in some cases (when references become "lost"), you may need to manually unload and re-load the Asset Chunks for the Grouping in order for the asset chunks to be detected as "new" and for them to trigger the OnAfterAssetChunksAdded method.

If storing the assets in a list, you may also need to check before using the assets to make sure they are not null (if they are null, they should be pruned from the list).

3) The World Cells passed into the OnAfterAssetChunksAdded method are fully configured and settings can be relied upon to be accurate, including the neighbors; however, there is no guarantee that the World Cells will remain valid after you return execution to calling code (for instance, they will be destroyed if you change which World Grouping is being edited by the World Designer Tool). As such, you should only use the World Cells in your method bodies and should not store references to them to be used later.

In addition to this, neighbors will not be set on World Cells when they are passed to the OnBeforeAssetChunksRemoved method, due to the nature of how the World Designer works. All values will be null!

4) It does not make much sense to make edits to the assets using this class, as the edits will be performed every time the asset is loaded and/or unloaded. Instead, this class is primarily intended to allow you to interface with other scripts that may need to know when an asset is loaded and unloaded, or to perform secondary logic.

If more than one listener is assigned to a Grouping, each listener is called in the order they appear in the World Designer Tool.

If you only care about specific LODs, use the LevelOfDetail property of the WorldCell to ignore Asset Chunks that don't belong to the LODs you care about!

Methods

OnAfterAssetChunksAdded(ReadOnlyList<object>, ReadOnlyList<WorldCell>)

public abstract void OnAfterAssetChunksAdded(ReadOnlyList<object> assetChunks, ReadOnlyList<WorldCell> cellsChunksBelongsTo)

This is called by the World Designer tool just after an Asset Chunks from a particular World Grouping and LOD have been added to the scene.

Parameters

Name Type Description
assetChunks ReadOnlyList<object>

The asset chunk objects that were just added.

cellsChunksBelongsTo ReadOnlyList<WorldCell>

The World Cells that the asset chunks belongs to. All data will be configured correctly, including the neighbors of each cell. Each index in this list corresponds to the same indexed item in the assetChunks lists, so you should use a for statement rather than a foreach to iterate through the asset chunks and world cells.

Because all assets in the assetChunks list are guaranteed to come from the same World Grouping and LOD, you can check the data of the first World Cell only to determine if your logic should run (perhaps you only want it to run for LOD 2, for example), or to perform custom logic for each LOD or World Grouping.


OnBeforeAssetChunksRemoved(ReadOnlyList<object>, ReadOnlyList<WorldCell>)

public abstract void OnBeforeAssetChunksRemoved(ReadOnlyList<object> assetChunks, ReadOnlyList<WorldCell> cellsChunksBelongsTo)

This is called by the World Designer tool just prior to a group of Asset Chunks from a particular World Grouping and LOD being removed from the scene.

Parameters

Name Type Description
assetChunks ReadOnlyList<object>

The asset chunk objects that are about to be removed.

cellsChunksBelongsTo ReadOnlyList<WorldCell>

The World Cells that the asset chunks belongs to. All data will be configured correctly, excepting the neighbors of each cell. Each index in this list corresponds to the same indexed item in the assetChunks lists, so you should use a for statement rather than a foreach to iterate through the asset chunks and world cells.

Because all assets in the assetChunks list are guaranteed to come from the same World Grouping and LOD, you can check the data of the first World Cell only to determine if your logic should run (perhaps you only want it to run for LOD 2, for example), or to perform custom logic for each LOD or World Grouping.