Search Unity

How to load a list of Texture2D assets using the label

Discussion in 'Addressables' started by douglassophies, Sep 5, 2019.

  1. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    96
    I have a collection of mouse icons (of type Texture2D) that i want to load locally.
    These are the steps i take:
    1. Mark assets as addressable
    2. Add a label and assign to the assets
    3. Build drop down > build player content
    Then i try the address:
    Code (CSharp):
    1. AsyncOperationHandle<IList<IResourceLocation>> locationHandle = Addressables.LoadResourceLocationsAsync("cursorIcons", null);
    But the locationHandle.Result is null. Am i missing something?
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    268
  3. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    913
    As stated, could be lots of issues, but most likely is that you aren't waiting for the op to finish. It's an async op, so Result will be null to start.
     
  4. douglassophies

    douglassophies

    Joined:
    Jun 17, 2012
    Posts:
    96
    Thanks for the reply. In other variations, i use the Completed event to call a function that would check for null so i was handling the async.
    I decided to load one by one instead of using the label to load them all at once as its not much of an issue for my project. That works fine for now.