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

Bug (Case #1272172) Addressables 1.14.2 Broke sprites again :(

Discussion in 'Addressables' started by CDF, Aug 21, 2020.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,282
    It's like every 2 releases sprite support stops working.
    Here's the latest:

    after upgrading from 1.13.1 and selecting an object that had an AddressableSprite reference, the inspector is spammed with this:

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.AddressableAssets.GUI.AssetReferenceDrawer.CheckTargetObjectsSubassetsAreDifferent (UnityEditor.SerializedProperty property, System.String objName, System.Int32 currentIndex, System.Int32& selIndex) (at Library/PackageCache/com.unity.addressables@1.14.2/Editor/GUI/AssetReferenceDrawer.cs:534)
    3. UnityEditor.AddressableAssets.GUI.AssetReferenceDrawer.DrawSubAssetsControl (UnityEditor.SerializedProperty property, System.Collections.Generic.List`1[T] subAssets) (at Library/PackageCache/com.unity.addressables@1.14.2/Editor/GUI/AssetReferenceDrawer.cs:497)
    4. UnityEditor.AddressableAssets.GUI.AssetReferenceDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Library/PackageCache/com.unity.addressables@1.14.2/Editor/GUI/AssetReferenceDrawer.cs:284)
    5. UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <d1bec46880064709a5e713ad543e6d96>:0)
    6. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <d1bec46880064709a5e713ad543e6d96>:0)
    7. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <d1bec46880064709a5e713ad543e6d96>:0)
    8. UnityEditor.EditorGUI.PropertyFieldInternal (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <d1bec46880064709a5e713ad543e6d96>:0)
    9. UnityEditor.EditorGUI.PropertyField (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <d1bec46880064709a5e713ad543e6d96>:0)
    Then at runtime, trying to load the asset results in a invalid key error.

    Code (CSharp):
    1. Exception encountered in operation CompletedOperation, status=Failed, result= : Exception of type 'UnityEngine.AddressableAssets.InvalidKeyException' was thrown., Key=af200ade86f0a6c429a6a0934f7acbfd, Type=UnityEngine.Sprite
    2. UnityEngine.AddressableAssets.AssetReferenceT`1:LoadAssetAsync()
    You can't just drag a sprite onto the asset reference field anymore (Event though the UI lets you!). You need to expand the sprite asset and drag the sub object into the reference field.

    This doesn't work anymore:
    sprite_old.png

    This does:
    sprite_new.png

    So great. I can't change the reference because UI is bugged and I can't load my game anymore.
    Downgrading to 1.13.1.
    I don't get it. Why are sprites so difficult to work with in Addressables?

    This needs to be simpler.
     
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,282
    At the end of the day I just want to do this:

    Code (CSharp):
    1. reference.LoadAssetAsync().Completed += OnSpriteLoaded;
    2.  
    3. void OnSpriteLoaded(AsyncOperationHandle<Sprite> handle) {
    4.  
    5.     handle.Completed -= OnSpriteLoaded;
    6.  
    7.     if (handle.Status == AsyncOperationStatus.Succeeded) {
    8.  
    9.         //set the sprite
    10.     }
    11. }
    I don't care if it's atlased or not. I don't want to manage atlases, whether they're included in build, master atlas, etc.
    All that is so confusing.
    I just want the sprite reference.
    Surely the addressables system can figure that stuff out automatically?
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,796
  4. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,282
    Sure thing.

    Case #1272172

    Here's a video also showing the issue as well (also in bug report):
     
  5. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    687
    I am getting this error as well. I can't even change the asset in the inspector because the exception causes the propertydrawer to disappear in the inspector. Please tell the team to test their code before releasing. Addressables is no longer in preview and these sorts of obvious defects are unacceptable.
     
  6. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    damn i just got this errror using 1.16.10
     
  7. Solorino78

    Solorino78

    Joined:
    Nov 21, 2016
    Posts:
    1
    I got the same error on 1.16.10 and 1.16.12.
    This was working fine on 1.16.7
     
  8. dht-8biteam

    dht-8biteam

    Joined:
    Jun 27, 2018
    Posts:
    7
    I got this error on 1.16.13 too