Move assets from the Resources system
If your project uses the Resources system to load assets, you can migrate those assets to the Addressables system:
- Make the assets Addressable. To do this, either enable the Addressable option in each asset's Inspector window or drag the assets to groups in the Addressables Groups window.
- Change any runtime code that loads assets using the
Resources
API to load them with theAddressables
API. For more information, refer to Load asset references. - Add code to release loaded assets when no longer needed.
If you keep all the former Resources assets in one group, the loading and memory performance is equivalent.
When you mark an asset in a Resources folder as Addressable, the system automatically moves the asset to a new folder in your project named Resources_moved
. The default address for a moved asset is the old path, omitting the folder name. For example, your loading code might change from:
Resources.LoadAsync\<GameObject\>("desert/tank.prefab");
to:
Addressables.LoadAssetAsync\<GameObject\>("Resources_moved/tank.prefab");.
Update Resources code
You might have to implement some functionality of the Resources
class differently after modifying your project to use the Addressables system.
For example, consider the Resources.LoadAll
method. Previously, if you had assets in a folder named Resources/MyPrefabs/
, and ran Resources.LoadAll\<SampleType\>("MyPrefabs");
, Unity loads all the assets in Resources/MyPrefabs/
matching type SampleType
. The Addressables system doesn't support this exact functionality, but you can achieve similar results using Addressable labels.