Give Page Feedback | API

Chunk Streamers - Overview

Chunk Streamers are responsible for getting new Asset Chunks into the scene and removing Asset Chunks that are no longer needed from the scene. Many of the most common methods for loading/unloading assets have been covered by the default Chunk Streamers, including loading/unloading scenes (either Addressable or not) and instantiating/destroying prefabs (again, either addressable or not), however you are free to create Custom Chunk Streamers to add other loading/unloading methods (including future ones Unity might add).

In addition, you can use them to change the logic behind what is loaded. This is especially useful for procedural worlds, where rather than loading a preset group of Asset Chunks based on an editor configured layout, the determination about which Asset Chunks to load is determined at runtime.

No matter which option you choose, you will find dedicated Sections for each within this Chapter.

Common Concepts

The remaining Sub Sections cover concepts common to all Default Chunk Streamers, therefore rather than re-write the same information on each Chunk Streamer Section, we have decided to put the information here.

Single/Double Frame Loading

The preferred and most performant way of loading Asset Chunks is over multiple frames, however when the Component Manager is initialized in a non-gradual manner, the ability to load Assets in one or two frames becomes necessary. Out of the four default Chunk Streamers, only the Addressable Scene Streamer is incapable of single/double frame loading. In addition, on the WebGL platform, the Addressable Prefab Streamer is also incapable of single/double frame loading.

When possible, single frame loading is preferred, however for some asset types, a pre-load frame is required to get the assets into the scene within two frames (for example, scenes).

When creating custom Chunk Streamers, it's up to you on whether you want to support Single/Double Frame Loading. If you don't want to or can't support it, simply avoid using non-gradual Component Manager Initialization.

Chunk Streamer Users

Each LOD Group that uses a Chunk Streamer registers with it. When it does, the streamer creates a special user object internally to store user related data, and gives calling code an ID so that when they communicate with the Streamer, the Streamer will know which user data to use for load/unload operations. This allows Chunk Streamer's to be used with multiple users, so long as all users find the Chunk Streamer's settings (set in its inspector) acceptable.

Controlling The Speed Of Loading

The speed at which resources are loaded asynchronously is controlled via Unity's Application.backgroundLoadingPriority property. You can set this value manually or let the Chunk Streamer do it for you by enabling Set Load Priority and choosing an option from the Load Priority setting. This value controls the amount of time all asynchronous operation have per frame to perform integration work with the main thread.

A lower value will be more performant but loading will be slower, while a higher value may be less performant but will result in faster loading.

Note that these settings are global and apply to all Chunk Streamers (including custom ones). You can adjust the settings on any Chunk Streamer you have in any of your scenes, and the changes will apply across all Streamers.

Async Load Strategy

All of the Default Chunk Streamers allow you to control the number of Asset Chunks which are asynchronously loaded at the same time:

1) One Chunk At A Time - Only a single Asset Chunk will be loaded by the Streamer at a time.

2) One Cell At A Time - All Asset Chunks belonging to a World Cell will be loaded at the same time.

3) All Together - All Asset Chunks from all World Cell's (in a single LoadAndAttachChunksToCells method call) are loaded at the same time.

It should be noted that since performance/loading speed is already controlled by Application.backgroundLoadingPriority, it makes little sense in most instances to use anything other than All Together. The other options will usually just slow loading speed at no benefit to performance. However, this is not a guarantee and if you notice a performance issue related to the Chunk Streamer, you can certainly try changing the option to something else to see if it makes a difference.

One Chunk At A Time will result in slightly better load progress tracking, which at the present time just means more accurate load progress tracking of the Component Manager's InitializeGradually method (which is useful for displaying loading bars). One Cell At A Time has inferior progress tracking, but it's better than All Together. This is because Unity's progress tracking for async loading methods breaks down when multiple async calls occur at the same time.