Give Page Feedback | API

Chunk Streamers - Prefab Chunk Streamer

This Chunk Streamer can be used to load non Addressable Prefab Assets. It is capable of single frame loading via the use of the Resources.Load method, however under normal runtime operation it uses Resources.LoadAsync for slower but more performant loading.

Creating A Prefab Chunk Streamer Component

You can add this component by selecting a game object and then selecting from the Top Menu Bar:

Component -> Deep Space Labs -> -> SAM -> Chunk Streamers -> Prefab Chunk Streamer

Adding A Prefab Chunk Streamer Component From The Top Menu Bar GIF

or by selecting a game object and using the Add Component menu via its inspector:

Component -> Deep Space Labs -> -> SAM -> Chunk Streamers -> Prefab Chunk Streamer

Adding A Prefab Chunk Streamer Component From Add Component Menu GIF

Chunk Destroyer

Chunk Destroyers are special components that can be used to control the manner in which Asset Chunks are destroyed.

When this field is null, the root Asset Chunk game object is destroyed, which will in turn destroy any children, grandchildren, etc. This may result in performance issues if your Asset Chunk contains a significant number of child/grandchild/etc. because everything is destroyed in a single frame.

ChunkDestroyers let you control the number and order that children/grandchildren are destroyed each frame.

Learn More About Chunk Destroyers

Memory Freeing Strategy

This setting gives you control over if and when Unity's Resources.UnloadUnusedAssets method is called. This is useful in situations where simply destroying the Asset Chunks using GameObject.Destroy does not release all memory tied to the GameObject.

For example, if you access the material property of a Renderer component, Unity creates a material instance under the hood, which needs to either be destroyed directly using its reference or unloaded via Resources.UnloadUnusedAssets.

--Special Note--
If using a Per Material Transitioner with its Use Shared Material option disabled, the transitioner will access the material property, creating a material instance resulting in a situation where the material instances need to be destroyed manually or via Resources.UnloadUnusedAssets. As such, it is recommended to use a Memory Freeing Strategy other than Dont Free Memory with Asset Chunks being used in this way.

Prepending Extra User Data

By default, Prefab Chunk Streamers expect prefabs assets to be placed directly inside folders named Resources, and not within subfolders.

If that is not the case for your assets, that's okay, however a bit of extra setup is required. Basically, it's necessary to tell the Prefab Chunk Streamer the sub folder path within the Resources folder where your prefab assets are located. While we could do this by specifying a fixed path, that would result in all Asset Chunks loaded by the Streamer to have to be in the same folder, a practice that would be terrible for Project Organization.

To avoid this problem, we make use of Extra User Data on Streamable Grids, where we can store global Streamable Grid data or LOD specific data.

Interested In Extra User Data?

In this case, the extra user data we want to store is the sub folder path within the Resources folder where your prefab assets are stored. You are free to store this data using whatever key you wish, however we recommend using the default Resources Sub Folder Path key. Use the Copy Folder button to get the folder path in the correct format (select the folder in the left pane of the Project Hierarchy first!).

Enable the Prepend Extra User Data option on the Prefab Chunk Streamer, and by default you will see that the Prepend Data Key is set to Resources Sub Folder Path. If you stored the sub folder data using this key, you do not need to make any changes to this setting; otherwise change the key to match whatever string you used to store the data.

By using data from the LOD Groups using the Streamer rather than data from the Streamer itself, the Streamer is able to be used with multiple LOD Groups, even when the Asset Chunks of those groups are stored in different sub folders.

Load In Deactivated State

You can enable this option and all prefabs game objects loaded by the streamer will be loaded in a deactivated state. This is very handy to keep the prefabs from being seen before they are correctly placed (which occurs at a later time).