Search Unity

Addressables.LoadAssetsAsync failing with key + label where key is a SpriteAtlas[Sprite]

Discussion in 'Addressables' started by ChrisHarshman, Oct 30, 2019.

  1. ChrisHarshman

    ChrisHarshman

    Joined:
    Oct 24, 2016
    Posts:
    16
    Hello,

    I am getting a crash because this code is not working as expected based on the samples. For some reason not sure why it cannot find the sprite, but it should be able to right?

    I took a look at the Texture Variations sample project which is what I used to base the code on for this text project, however that project worked fine when not using sprite atlases and just referencing textures.

    I tested out everything in the latest Unity 2019.3 beta.

    Code
    Code (CSharp):
    1.  
    2. string key = "skin[metalPanel]";
    3. string label = "green";
    4. Addressables.LoadAssetsAsync<Sprite>(new List<object> { key, label }, null, Addressables.MergeMode.Intersection).Completed += SkinSprite_Completed;
    5.  
    I should note that this only happens with Intersection, if I try the other modes, it will return all three sprites of that name in an atlas with that name.

    Error
    Code (CSharp):
    1. Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[System.Collections.Generic.IList`1[UnityEngine.Sprite]], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=System.Collections.Generic.List`1[System.Object]
    2. UnityEngine.AddressableAssets.Addressables:LoadAssetsAsync(IList`1, Action`1, MergeMode)
    Addressesables Window


    Sample Project
    If this is a bug, I have a sample project here: https://1drv.ms/u/s!AgVjGtnivjOEiYQtHvttAPAKHhSUgQ?e=G7ZyXs

    You just need to run the game with the scene, click create and then change the dropdown box to another option.

    Update:

    I can confirm that if I search for the SpriteAtlas and then pull the Sprite using GetSprite it will work, so there is a workaround, but this clearly seems like a bug now.
     
    Last edited: Nov 1, 2019
    ErotesGames likes this.
  2. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Hey @ChrisHarshman that does sound like a bug. Thanks for providing the sample project. Would you mind submitting a bug report and posting the case number here? It'll help us keep track of it better. Thank you
     
  3. ChrisHarshman

    ChrisHarshman

    Joined:
    Oct 24, 2016
    Posts:
    16
    Last edited: Nov 1, 2019
    ErotesGames and davidla_unity like this.