[0.7.4] Property Drawer error

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)

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?

@unity_bill Here’s some examples of how I used it. It’s the same error across in-scene object, prefab, scriptable.

using System;
using UnityEngine;
using UnityEngine.AddressableAssets;

public class TargetReference : ScriptableObject
{
    [Serializable] public class AssetReferenceTarget : AssetReferenceT<TargetAssetList> { public AssetReferenceTarget(string guid) : base(guid) { } };
    [SerializeField] AssetReferenceTarget[] assets = default;
}

using UnityEngine;
using UnityEngine.AddressableAssets;

public class Props : MonoBehaviour
{
    [SerializeField] AssetReferenceGameObject propMenu = default;
}

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.

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.

4477363--411703--GIF.gif

using UnityEngine;
using UnityEngine.AddressableAssets;

[CreateAssetMenu]
public class DrawerTest : ScriptableObject
{
    [System.Serializable]
    public class Test : TestT<int>
    {

    }

    [System.Serializable]
    public class Test2
    {
        [SerializeField]
        AssetReferenceGameObject music;
        [SerializeField]
        int integer;
    }

    [System.Serializable]
    public class TestT<T>
    {
        [SerializeField]
        Music music;
        [SerializeField]
        T integer;
    }

    [System.Serializable]
    public class Music
    {
        [System.Serializable]
        public class MusicAssetReference : AssetReferenceT<AudioClip>
        {
            public MusicAssetReference(string guid) : base(guid) { }
        }

        public MusicAssetReference clips;
    }

    [SerializeField]
    Music testSimple;
    [SerializeField]
    Music[] testSimpleArray;
    [SerializeField]
    Test test;
    [SerializeField]
    Test2 test2;
}

At least the issue reported here AssetReferenceDrawer does not dirty the SerialziedProperty seems to be fixed since I’m using the same code I used to report it there.

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

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.GenericInspector.OnOptimizedInspectorGUI (UnityEngine.Rect contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/GenericInspector.cs:98)
UnityEditor.UIElements.InspectorElement+<CreateIMGUIInspectorFromEditor>c__AnonStorey1.<>m__0 () (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorElement.cs:439)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

I fixed the errors by completely removing addressables, clearing the Library cache, restarting, then reinstalling addressables.

we fixed this in 0.8.4 but forgot to mention it in the changelog.

1 Like

Thanks @unity_bill !