All Addressable related code is provided as source code within the project, in special folders that have been configured with Assembly Definition Files that detect whether Unity's Addressables package is in your project.
If this package is not in your project, the source code is either stripped of the parts related to Addressables, or stripped completely. This allows the Addressable related SAM Source Code to sit in projects with and without the Addressables package.
Please keep in mind that the Addressables system is somewhat complicated and recommended for users who know what they are doing! We do not offer assistance in setting up standard Addressable settings; you must navigate these settings yourself by watching tutorial videos or using Unity's documentation.
The Addressables package can be added using Unity's Package Manager
There are no version requirements for which Addressables package you use, however we recommend using the latest one available with your Unity version as it will usually be more stable and contain less bugs.
Obviously, if your project already contains an Addressables Package, you can skip this step, however if you are not on the latest version we encourage you to upgrade.
All code needed to support Addressable use with the World Designer tool is already included, however you need to execute the following two Assets Menu commands in order to enable Addressable Use with the World Designer Tool:
1) Assets - > Deep Space Labs -> SAM -> Regenerate Default Addressable Prefab Asset Manager
2) Assets - > Deep Space Labs -> SAM -> Regenerate Default Addressable Scene Asset Manager
These commands create two new Asset Manager assets inside of the Assets/Editor Default Resources/Deep Space Labs/SAM/AssetManagers folder, which are required by the World Designer tool to work with Addressable Assets. For now, that's all you should need to know, however if you are interested in learning more about Asset Managers, you can open the relevant Section using the button below.
--Special Note--
If you do not see these commands in the Assets Menu, you likely need to Save and Close your Project and reopen it. This will refresh the Assembly Definition Files and enable the source code that is Addressable Dependent.
Runtime streaming of Addressable Assets is performed by a Chunk Streamer configured to load them. By default, we include two Streamers that fit this criteria, the Addressable Prefab Chunk Streamer and Addressable Scene Chunk Streamer. It should be evident, but the difference between the two is that one is setup to load Prefabs and the other Scenes.
You are free to create a custom Chunk Streamer that streams in these Addressable Assets in a different way, or one that is capable of streaming in different types of Addressable Assets. For now, however, it should be sufficient to start using one of the two default Streamers. You can find more information about them using the buttons below.
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 should not be marked as Addressable, so that they can be pulled in automatically by Unity into the same Asset Bundle as their Chunk, 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), or you manually call the Resources.UnloadUnusedAssets method. Unfortunately, this method is very costly in terms of performance, so we don't recommend using during normal gameplay (i.e,. any where 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.
It can be tempting to use only two Groups for your entire project (one set to Pack Separately and one set to Pack Together), and at the end of your project lifecyle 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.
Note that the above are general guideliness. You should always profile your game builds to see what is using memory! The Asset Profiler can be especially useful for this, as it can show you problematic assets that are hanging around too long when using the Pack Together approach.
If you already have Prefab or Scene Asset Groups and want to convert them to Addressables, the process is very simple. Simply create an Addressable Group to add the Addressables to, select all of the assets from the same group that you want to convert, and drag them onto the Group via the Addressables Group Window (Window -> Assets Management -> Addressables -> Groups).
When you drag and drop assets in the way described above, the addresses of each Addressable Asset automatically includes the folder path where the assets are stored. While this is beneficial in many ways, issues can arise on some Operating Systems such as Windows because the final output folder path where the Asset Bundles are built can become longer than the allowed amount.
As such, we recommend placing Addressable Assets at most 1 sub folder deep within the Project Hierarchy, and using a very short sub folder name. In addition, if possible, the common name all Assets in the Group share (the Group Name) should be as short as possible. Doing so will reduce the likelihood of this being a problem. If there is an issue, it will appear during the Addressable Build operation.
If you are using Asset Creators to create your Addressable Assets, you can also setup the Creator to not include the folder path at all in the Address. Do note that you must ensure all Addressable Assets are uniquely named when doing this.