Give Page Feedback | API

Chunk Destroyers - How To Create Custom Chunk Destroyer

Custom Destroyers are useful if your Asset Chunks have deep hierarchies, as you can control the order and quanity of game objects destroyed. This is most especially useful when there are a great many child/grandchild objects on each root Asset Chunk, as generally you will want to limit the number of them that are destroyed each frame, so as not to negatively affect performance.

In order to create a custom Chunk Destroyer, start by creating a new MonoBehaviour script that derives from the ChunkDestroyer base abstract class.

You should place your class inside of the DeepSpaceLabs.SAM namespace, which will make the ChunkDestroyer class available and also help avoid naming conflicts with 3rd party assets or your own code.

--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.

In addition, we recommend adding the following attribute above your class, which will ensure the custom chunk manager is shown with other Chunk Destroyers in menus:

[AddComponentMenu(GlobalValues.COMPONENT_ROOT_PATH + "Chunk Destroyers/Custom Chunk Destroyer Name")]

DestroyChunksOnCells (Method - Implementation Required)

When called, this method should destroy all Asset Chunks belonging to the input cells. The MemoryFreeingStrategy set in the Chunk Streamer the Destroyer is assigned to is passed into the method, however it's up to you whether you want to make use of it.

A ChunkStreamer.ChunkStreamerUser object is also passed in, which can give you different information about the LOD Group whose chunks you need to destroy. You may or may not need to make use of this information.