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.

Methods

DestroyChunk(GameObject, ChunkStreamer.ChunkStreamerUser)

public sealed override IEnumerator<YieldInstruction> DestroyChunk(GameObject chunk, ChunkStreamer.ChunkStreamerUser ChunkStreamerUser)

Destroys a single chunk (game object). If the chunk has children, objectsToDestroyPerFrame controls how many total game objects are destroyed per frame.

Parameters

Name Type Description
chunk GameObject

The chunk (game object) to destroyed.

ChunkStreamerUser ChunkStreamer.ChunkStreamerUser

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

Returns

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


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

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

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.

Returns

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