Give Page Feedback

Addressable System - Optimizations

In this section we offer some optimization tips that we have discovered while using the Addressable System in our own work. Please keep in mind that most of this is generalized advice, and your own specific use case my require a different approach! Always profile your builds! The Addressable Assets Profiler Module is very handy for finding assets that are hanging around too long, and for generally investigating the loading process when using Addressables. The Memory Profiler is also very useful for this. In a simple test, try loading your game, moving your player all around your map, then navigating back to the starting position. The memory use at the start and at the end should generally be very similar, and if it's not, it's likely that there are assets being loaded in but never unloaded (although this is not always the case).

Bundle Mode

Unity offers the general advice to pack assets into the same Asset Bundle when they are loaded and unloaded together, and in general this is good advise when your Asset Chunks are relatively lightweight. However, when using more memory intensive and/or complex Asset Chunks, this strategy creates problems as the file processing operations for the larger Asset Bundles can lead excessive CPU use (which can lead to lag spikes)

As such, our suggestion is to place SAM Prefab/Scene Asset Chunks (whichever you are using) into Addressable Groups set to Pack Separately, unless they are truly very lightweight, in which you can use the Pack By Tag with a Default Asset Creator set to add Row/Column/Layer tags to the Asset Chunks.

Larger Dependencies (of your Asset Chunks), such as textures, meshes, etc. which are only used by a few Asset Chunks should be placed in their own bundles, which means you can also add these to your Pack Separately Group. Dependencies which are only used by one Asset Chunk, or which are used by a few Asset Chunks that are never loaded together, should not be marked as Addressable, so that they can be pulled in automatically by Unity into the same Asset Bundle as the Chunks that use them (during the Addressable Build process).

For smaller dependency assets which are used by many of your Asset Chunks, we recommend placing them into a Group set to Pack Together, however you should note the following.

When assets are packed together into a single Asset Bundle (behavior of Pack Together in the Group settings), each asset will only take up memory after being loaded for the first time (awesome!). However, those assets will remain in memory until all the assets in the bundle are no longer referenced (i.e., no Asset Chunks using any of the assets are loaded). You can technically overcome this limitation by manually calling the Resources.UnloadUnusedAssets method, however this method is very costly in terms of performance, so we don't recommend using during normal gameplay (i.e., anywhere the player would notice a lag spike). If you have a dependency asset which is larger in terms of how much memory it takes up, and that asset is only used by a few Asset Chunks, you should probably place it in the Pack Separately group so that it is contained in its own Asset Bundle, which will allow it to be efficiently unloaded from memory when it is not in use.

How Many Addressable Groups Should I Use?

It can be tempting to use only two/three Groups for your entire project (one for each bundle mode), and at the end of your project lifecycle such a strategy would be optimal. However, during development we would recommend splitting content into different Addressable Groups by Zone. This will allow you to enable/disable Groups during testing, in order to make smaller/faster builds with only the content that is needed for a particular test.

In addition, it is also common to have global assets that are needed in your game at all times, regardless of which content is loaded. These types of assets (shaders usually fall into this category) should usually be placed in their own Addressable Group set to either Pack Together or Pack Separately (only if the assets are very large).

Asset Bundle Compression and CRC

If using the Asset Bundle cache, using LZMA compression is recommended, as it will reduce the size of the asset bundles, thus reducing the amount of data that needs to be downloaded over the internet. When the bundles are stored in the cache, Unity automatically re-compresses then in LZ4 format for faster decompression when those bundles are needed in game.

Regarding the CRC, Enabled, Excluding Cached is generally recommended across the Unity interweb, however you should feel free to do your own investigation to determine the best setting for your game.