Loading Asset Locations using IList<IResourceLocation>

Badger Dox
2 min readNov 27, 2019

--

Project & Code

Would you like more help? Need to talk some game dev.? Looking for feedback? Join the discussion on Discord

Store loaded locations in order to create assets at a later time. The overhead to these references is much smaller than having a gameobject inactive in the hierarchy. Start by creating a game object within the hierarchy and call it AssetHolder. Next, create two classes AddressableLocationLoader and LoadedAddressableLocations. Attach the LoadedAddressableLocations to the game object AssetHolder.

AddressableLocationLoader

  • Search for all locations that share a specific label
  • Wait until locations have finished loading
  • Add loaded locations into a provided list

LoadedAddressableLocations

  • Monobehaviour
  • Calls when assets are to be loaded
  • Holds loaded assets in collection

Open up AddressableLocationLoader in your code editor and type in the snippet into your class. The class will be static so that it can be called at any time without needing a reference for it. There will be one static async method, giving us additional control over loading operations.

Labels are keys that allow for additional identification of similar resources

After the code has been entered open LoadedAddressableLocations this class will store our loaded reference locations. To wait until a specific operation has completed, the single method within the script will be async.

If anything is cut off full script — https://tinyurl.com/qvepgsa

Tip — Use the primary key of an IResourLocation to get its Addressables name

Go back into and test the project. In your console after a few milliseconds, you will see the name of your assets pop up! In the case below you would see “Circle” and “Triangle”.

You’ve done it! You’ve got the basics to download asset locations at your fingertips. Check out the next installment, how to instantiate from a loaded address.

Have you found this post helpful? Please feel free to share it wherever you think it would encourage others.

Want more details about anything within the post, please leave a comment and I’ll respond as thoroughly as possible. Are you looking for a subject that wasn’t covered, suggest it and I’ll get busy filming and throwing together a write-up.

--

--