Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Load assets using Label? [Resolved]

Discussion in 'Addressables' started by Opeth001, Jul 15, 2019.

  1. Opeth001

    Opeth001

    Joined:
    Jan 28, 2017
    Posts:
    649
    Is it possible to load all addressable assets directly via label ?

    EDIT:
    i found it.

    Addressables.LoadAssetsAsync<GameObject>(MyLabelString, null).Completed += objects =>
    {
    foreach (var go in objects.Result)
    Debug.Log($"Addressable Loaded: {go.name}");
    };
     
    Last edited: Jul 15, 2019
  2. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    493
    Just found this as well, its really odd we need to pass a callback when we also get it as a result.
     
  3. nicmarxp

    nicmarxp

    Joined:
    Dec 3, 2017
    Posts:
    302
    Thanks, works great!
    @TJHeuvel-net isn't that because it's async? If you put Debug.Log(Time.time) inside the callback and after the callback, the inside will be called slightly after.

    Objects is an IList<GameObject> or whatever type you put in the LoadAssetsAsync call.
     
  4. e-khezri

    e-khezri

    Joined:
    Aug 23, 2013
    Posts:
    11
    I think this hasn't been mentioned anywhere in the documentation. the asset label name needs to have brackets. I meant the label name pattern should be as follow [labelName] otherwise it won't work.
     
    mahdad_baghani likes this.
  5. crawfis

    crawfis

    Joined:
    Jan 30, 2014
    Posts:
    28
    @e-khezri. You do not need brackets and none of the examples use them, nor do I.
     
  6. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,749
    This does not work with getting Sprites in Sprite Sheet.

    So say :

    Addressables.LoadAssetsAsync<IList<Sprite>>("Sprite", null);

    Does not work.
     
  7. Ardito92ITA

    Ardito92ITA

    Joined:
    Apr 1, 2014
    Posts:
    13
  8. calabi

    calabi

    Joined:
    Oct 29, 2009
    Posts:
    125
    Awesome, thanks a lot for this. Trying to figure this stuff out with just the docs is a nightmare
     
unityunity