Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Can't load an atlased sprite (everything else loads fine)

Discussion in 'Addressables' started by Lance-Grooms, Jun 8, 2020.

  1. Lance-Grooms

    Lance-Grooms

    Joined:
    Mar 24, 2016
    Posts:
    26
    At a loss here. I must be missing some basic info.


    Code (CSharp):
    1.  public class MyApp : MonoBehaviour
    2. {
    3.         // Set to proper values in the editor
    4.    
    5.         public AssetReferenceSprite NonAtlased;
    6.         public AssetReferenceSprite AtlasedSprite;
    7.  
    8.         void Awake()
    9.         {
    10.             Invoke("StartTest", 0.1f);
    11.         }
    12.  
    13.         public void StartTest()
    14.         {
    15.             // Load atlas and load non-atlased sprites work fine
    16.        
    17.             Addressables.LoadAssetAsync<SpriteAtlas>("TestAtlas").Completed += OnAtlasLoaded;
    18.             NonAtlased.LoadAssetAsync().Completed += OnSpriteLoaded;
    19.  
    20.             // Any atlas sprite loading fails, even if called after the atlas is loaded
    21.  
    22.             Addressables.LoadAssetAsync<Sprite>("TestAtlas[TestHeart]").Completed += OnSpriteLoaded;
    23.             AtlasedSprite.LoadAssetAsync().Completed += OnSpriteLoaded;
    24.  
    I get the following for atlased sprites:

    Exception encountered in operation UnityEngine.ResourceManagement.ResourceManager+CompletedOperation`1[UnityEngine.Sprite], result='', status='Failed': Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=, Type=UnityEngine.Sprite
    Exception encountered in operation UnityEngine.AddressableAssets.Initialization.InitializationOperation, result='', status='Succeeded' - Chain<Sprite>: ChainOperation of Type: UnityEngine.Sprite failed because dependent operation failed

    Any ideas? Is there a manual "build atlases" step I'm missing?
     
  2. Lance-Grooms

    Lance-Grooms

    Joined:
    Mar 24, 2016
    Posts:
    26
    This appears fixed in 1.10 (although I can't get data to appear in my event viewer now).