AddressablePrefabChunkStreamer Class

public sealed class AddressablePrefabChunkStreamer : AddressableBaseChunkStreamer

An implementation of AddressableBaseChunkStreamer that is able to stream in Addressable Prefabs. You cannot override this class, however you can consult this page as a reference if implementing your own custom addressable chunk streamer.

Properties

Name Type Description
ChunkDestroyer ChunkDestroyer

Gets the Chunk Destroyer associated with this component.

By default, when DetachAndUnloadChunksFromCells is called, the streamer calls GameObject.Destroy for each chunk/cell object that needs to be removed from the scene, decrements the count of loaded instances for the addressable associated with the chunk/cell object, and then Releases the addressable handle which should free memory.

If your chunk/cell object has many children, you may wish to use a custom Chunk Destroyer in order to destroy the children across several frames to avoid FPS spikes.

Do keep in mind, unlike other Chunk Streamers that make use of the Chunk Destroyer class, this streamer will use the destroyers DestroyChunk method rather than its DestroyChunksOnCells method. The reason for doing so is that after destroying each chunk/cell object, the count of loaded instances for the addressable associated with the chunk/cell object needs to be decremented, so that its handle can be released when the count reaches 0.

FileExtension string

File extension that is appended to addresses.

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. If you create a custom class deriving from Chunk Manager, you can choose to ignore the strategy or enforce it. Memory freeing is simply calling Resources.UnloadUnusedAssets (which can be used like any other coroutine!)

Methods

AwakeExtended2()

protected sealed override void AwakeExtended2()

Awake related logic is contained within this method.


CreateAddressableLoaderUser(LODGroup)

protected sealed override AddressableStreamerBaseUser CreateAddressableLoaderUser(ILODGroup LODGroup)

Creates a new AddressablePrefabLoaderUser object, which implements behaviour needed to load prefab addressable assets.

Parameters

Name Type Description
LODGroup ILODGroup

The lod group being registered.

Returns

AddressableStreamerBaseUser
A new AddressablePrefabLoaderUser user object created using the LODGroup as input.


DetachAndUnloadChunksFromCells(List<WorldCell>, int)

public sealed override IEnumerator<YieldInstruction> DetachAndUnloadChunksFromCells(List<WorldCell> cells, 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 objects 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, and generally only for testing purposes. Also note that since the AddressableErrorRepairer only works on a multi frame basis, it will no the called, and the streamer will automatically try to load the backup assets if any assets fail to load.

Parameters

Name Type Description
cells List<WorldCell>

The cells whose chunks need to be attached.

userID int

The ID of the user requesting the attachment.


OnDestroyExtended()

protected sealed override void OnDestroyExtended()

OnDestroy related logic is contained within this method.


StartExtended()

protected sealed override void StartExtended()

Start related logic is contained within this method.