SimpleChunkDestroyer Class

public sealed class SimpleChunkDestroyer : ChunkDestroyer

Provides a simple implementation for a Chunk Destroyer, which destroys a specific number of game objects per frame. The destroyer searches one level deep for child objects of each main chunk, and destroys those first before destroying the root chunk.

As the name implies, this is a rather simple implementation, and is not suitable for more complex child-parent hierarchies. In those cases, it is recommended to create a custom Chunk Destroyer.

This destroyer does a check to make sure the chunks on each World Cell are present before trying to destroy them, in situations where you manually destroy the chunks.

The destroyer attempts to limit the amount of frame time consuned by the destruction of Asset Chunks via the Min Objects To Destroy In A Single Frame value, since the destruction overhead is typically delayed until the end of the frame and thus cannot be tracked properly by the Execution Controller. Each first level child of each chunk, plus the chunk itself, is counted towards this value. If 'Count Grandchildren' is enabled, the grandchildren of each asset chunk are also counted. This count is carried over from one asset chunk to the next, so long as the destruction operation of of the next asset chunk begins in the same frame that the last chunk's destruction ended.

Methods

DestroyChunksOnCells(List<WorldCell>, MemoryFreeingStrategy, ChunkStreamer.ChunkStreamerUser, bool)

public abstract IEnumerator<YieldInstruction> DestroyChunksOnCells(List<WorldCell> cells, MemoryFreeingStrategy memoryFreeingStrategy, ChunkStreamer.ChunkStreamerUser ChunkStreamerUser, bool waitOnFinalMemoryFreeing)

Destroys x children per frame, where x is whatever you set the "Max Objects To Destroy In A Single Frame" option in the insepctor to.

Parameters

Name Type Description
cells List<WorldCell>

The cells with the chunks needing to be destroyed.

memoryFreeingStrategy MemoryFreeingStrategy

The Memory Freeing Strategy set in the inspector of the calling Chunk Manager. This method DOES make use of this value. If the value is set to 'Free After Each Chunk', when memory is freed after the root chunk object is destroyed, the destroyed object counter is reset to 0.

ChunkStreamerUser ChunkStreamer.ChunkStreamerUser

The user which triggered the method call. This object is not used by this method.

waitOnFinalMemoryFreeing bool

If memoryFreeingStrategy is not set to Dont Free Memory, this controls whether the destroyer will wait on the final memory freeing operation before yielding control back to the calling Chunk Streamer. Setting this to false may speed up the World Update Speed, or it may not, since the memory freeing strategy will block other Async operations from executing.

Returns

IEnumerator<YieldInstruction>
An IEnumerator<YieldInstruction> that can be iterated over or used as a coroutine. See the YieldInstruction page for more info.