Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[0.7.4] Property Drawer error

Discussion in 'Addressables' started by unknowndevice, Apr 23, 2019.

  1. unknowndevice

    unknowndevice

    Joined:
    Sep 13, 2016
    Posts:
    86
    Using Unity 2018.3.12f1, upgraded to 0.7.4 and I'm now getting the following error when viewing an AssetReference in the Inspector.


    MissingMethodException: UnityEngine.Hash128 UnityEngine.AddressableAssets.AssetReference.get_RuntimeKey()
    UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:23)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:139)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:106)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:180)
    UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:106)
    UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:208)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9229)
    UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at /Users/builduser/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9223)
    UnityEditor.Editor.DoDrawDefaultInspector (UnityEditor.SerializedObject obj) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:630)
    UnityEditor.Editor.DoDrawDefaultInspector () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:641)
    UnityEditor.Editor.DrawDefaultInspector () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:615)
    UnityEditor.Editor.OnInspectorGUI () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/Editor.cs:650)
    ReorderableArrayInspector.InspectorGUIStart (System.Boolean force) (at Assets/Editor/ThirdParty/Attributes/RedorderableList/ReorderableArrayInspector.cs:405)
    ReorderableArrayInspector.OnInspectorGUI () (at Assets/Editor/ThirdParty/Attributes/RedorderableList/ReorderableArrayInspector.cs:421)
    UnityEditor.InspectorWindow.DoOnInspectorGUI (System.Boolean rebuildOptimizedGUIBlock, UnityEditor.Editor editor, System.Boolean wasVisible, UnityEngine.Rect& contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1625)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    We haven't seen this. Can you paste the code of the object that has the reference? Also, what is it on? An in-scene object? prefab? scriptable object? other?
     
  3. unknowndevice

    unknowndevice

    Joined:
    Sep 13, 2016
    Posts:
    86
    @unity_bill Here's some examples of how I used it. It's the same error across in-scene object, prefab, scriptable.

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.AddressableAssets;
    4.  
    5. public class TargetReference : ScriptableObject
    6. {
    7.     [Serializable] public class AssetReferenceTarget : AssetReferenceT<TargetAssetList> { public AssetReferenceTarget(string guid) : base(guid) { } };
    8.     [SerializeField] AssetReferenceTarget[] assets = default;
    9. }
    10.  
    11. using UnityEngine;
    12. using UnityEngine.AddressableAssets;
    13.  
    14. public class Props : MonoBehaviour
    15. {
    16.     [SerializeField] AssetReferenceGameObject propMenu = default;
    17. }
     
    Last edited: Apr 24, 2019
  4. unknowndevice

    unknowndevice

    Joined:
    Sep 13, 2016
    Posts:
    86
    I don't get this error in 2019.1.0f2. so maybe it is specific to 2018.3 or something I've done with the configuration.
     
  5. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    The issue seems to be something with the cached values. I found how to replicate it easily and even how to "solve" it. As you can see all I had to do was add 1 element to an array and then it got fixed.

    GIF.gif

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.AddressableAssets;
    3.  
    4. [CreateAssetMenu]
    5. public class DrawerTest : ScriptableObject
    6. {
    7.     [System.Serializable]
    8.     public class Test : TestT<int>
    9.     {
    10.  
    11.     }
    12.  
    13.     [System.Serializable]
    14.     public class Test2
    15.     {
    16.         [SerializeField]
    17.         AssetReferenceGameObject music;
    18.         [SerializeField]
    19.         int integer;
    20.     }
    21.  
    22.     [System.Serializable]
    23.     public class TestT<T>
    24.     {
    25.         [SerializeField]
    26.         Music music;
    27.         [SerializeField]
    28.         T integer;
    29.     }
    30.  
    31.     [System.Serializable]
    32.     public class Music
    33.     {
    34.         [System.Serializable]
    35.         public class MusicAssetReference : AssetReferenceT<AudioClip>
    36.         {
    37.             public MusicAssetReference(string guid) : base(guid) { }
    38.         }
    39.  
    40.         public MusicAssetReference clips;
    41.     }
    42.  
    43.     [SerializeField]
    44.     Music testSimple;
    45.     [SerializeField]
    46.     Music[] testSimpleArray;
    47.     [SerializeField]
    48.     Test test;
    49.     [SerializeField]
    50.     Test2 test2;
    51. }
    At least the issue reported here https://forum.unity.com/threads/assetreferencedrawer-does-not-dirty-the-serialziedproperty.568894/ seems to be fixed since I'm using the same code I used to report it there.
     
  6. unknowndevice

    unknowndevice

    Joined:
    Sep 13, 2016
    Posts:
    86
    We don't appear to be having the same problem as that does not solve my issue. I've now upgraded to 2019.1.1f1 and 0.7.5 and the problem still persists in this project. Though the problem is not present in any other project. I'm probably just going to try and flush all references to addressables and see if that fixes the problem.

    Here's the error when I removed the other attribute errors @unity_bill

    Code (CSharp):
    1. MissingMethodException: UnityEngine.Hash128 UnityEngine.AddressableAssets.AssetReference.get_RuntimeKey()
    2. UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyDrawer.cs:23)
    3. UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at /Users/builduser/buildslave/unity/build/Editor/Mono/ScriptAttributeGUI/PropertyHandler.cs:139)
    4. UnityEditor.GenericInspector.OnOptimizedInspectorGUI (UnityEngine.Rect contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/GenericInspector.cs:98)
    5. UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:439)
    6. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
    Last edited: May 4, 2019
  7. unknowndevice

    unknowndevice

    Joined:
    Sep 13, 2016
    Posts:
    86
    I fixed the errors by completely removing addressables, clearing the Library cache, restarting, then reinstalling addressables.
     
  8. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    we fixed this in 0.8.4 but forgot to mention it in the changelog.
     
    Rotary-Heart likes this.
  9. unknowndevice

    unknowndevice

    Joined:
    Sep 13, 2016
    Posts:
    86