PrefabChunkStreamer Class

public sealed class PrefabChunkStreamer : ChunkStreamer

A Chunk Streamer which loads prefabs into the scene via the Resources.LoadAsync and Object.Instantiate methods (only when single frame loading is required), and unloads prefab chunks from the scene using an attached Chunk Destroyer or GameObject.Destroy if a destroyer is not present.

When using this component, the prefabs can be stored directly in a folder called Resources, or within a subfolder within the Resources folder. If stored in a sub folder, you will need to enable Prepend Extra User Data and provide a valid key in the Prepend Data Key field, that can be used to retrieve the sub folder path for each user of the loader (A user is a specific LOD from a specific Streamable Grid asset). More information can be found by hovering over the Prepend Extra User Data and Prepend Data Key fields in the inspector, or by consulting the in Editor Guide.

You should never have to interact directly with this component, as the methods/properties are called/used as needed by the Streamable Assets Manager.

Properties

Name Type Description
AsyncLoadStrategy AsyncLoadStrategy

Gets or sets the Async Load Strategy.

ChunkDestroyer ChunkDestroyer

Gets the Chunk Destroyer associated with this component.

ExtraDataToPrependKey string

See ChunkStreamer.ExtraDataToPrependKey for more information on this property. This implemention simply returns the value of 'Prepend Data Key' set in the inspector if 'Prepend Extra User Data' is true, or null if 'Prepend Extra User Data' is false.

IsSingleFrameAttachmentPreloadRequired bool

Because instantiated prefabs do not need a frame to "process", pre-loading is not required, and so this property is overridden to return false.

MemoryFreeingStrategy MemoryFreeingStrategy

The strategy for freeing memory, which basically determines if/when Resources.UnloadUnusedAssets() is called.

Methods

AwakeExtended()

protected sealed override void AwakeExtended()

Awake related code for the Prefab Chunk Streamer.


CreateNewUser(ILODGroup)

protected override ChunkStreamerUser CreateNewUser(ILODGroup LODGroup)

Creates a new PrefabInstantiatorUser, which is a custom type which derives from ChunkStreamerUser. This user object contains a CellString and some other data used specifically by this class.

Parameters

Name Type Description
LODGroup ILODGroup

The lod group being registered.

Returns

ChunkStreamerUser
A new user object created using the worldAssociatedWithUser as input.


DetachAndUnloadChunksFromCells(List<WorldCell>, int)

public sealed override IEnumerator<YieldInstruction> DetachAndUnloadChunksFromCells(List<WorldCell> deactivatedCells, int userID)

Detaches and unloads the chunks associated with the input world cells over a period of frames using the associated ChunkDestroyer, or GameObject.Destroy if no destroyer is present.

Parameters

Name Type Description
cells List<WorldCell>

The World Cells whose chunks need to be detached and unloaded.

userID int

The ID of the user requesting the unload and detachment.

Returns

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


LoadAndAttachChunksToCellsInSingleFrame(List<WorldCell>, int)

public sealed override void LoadAndAttachChunksToCellsInSingleFrame(List<WorldCell> cells, int userID)

Instantiates and attaches all cell chunks to the input cells in a single frame. This is not very performant and so should only be used in Awake or Start.

Parameters

Name Type Description
cells List<WorldCell>

The cells whose objects need to be attached.

userID int

The ID of the user requesting the attached.


LoadAndAttachChunksToCells(List<WorldCell>, int)

public sealed override IEnumerator<YieldInstruction> LoadAndAttachChunksToCellsInSingleFrame(List<WorldCell> cells, int userID)

Loads and attaches the chunks associated with the input cells to the cells over a period of frames.

Parameters

Name Type Description
cells List<WorldCell>

The cells whose chunks need to be loaded and attached.

userID int

The ID of the user requesting the load and attachment.

Returns

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