Skip to content

Inspector drawing fatal error #3

@MJRamon

Description

@MJRamon

When using as this:

    [SerializeField, SerializedDictionary("ItemData & GUID", "MetaData (JSON) & count")]
    private SerializedDictionary<KeyValuePair<ItemData, string>, KeyValuePair<string, int>> inventoryContainer = new SerializedDictionary<KeyValuePair<ItemData, string>, KeyValuePair<string, int>>();
    public SerializedDictionary<KeyValuePair<ItemData, string>, KeyValuePair<string, int>> InventoryContainer { get { return inventoryContainer; } private set { inventoryContainer = value; } }

Console is spammed with error:

NullReferenceException: Object reference not set to an instance of an object
AYellowpaper.SerializedCollections.Editor.SerializedDictionaryInstanceDrawer.DrawGroupedElement (UnityEngine.Rect rect, System.Int32 spaceForProperty, UnityEditor.SerializedProperty property, AYellowpaper.SerializedCollections.Editor.DisplayType displayType) (at Assets/Plugins/SerializedCollections/Editor/Scripts/SerializedDictionaryInstanceDrawer.cs:657)
AYellowpaper.SerializedCollections.Editor.SerializedDictionaryInstanceDrawer.OnDrawElement (UnityEngine.Rect rect, System.Int32 index, System.Boolean isActive, System.Boolean isFocused) (at Assets/Plugins/SerializedCollections/Editor/Scripts/SerializedDictionaryInstanceDrawer.cs:644)
UnityEditorInternal.ReorderableList.DoListElements (UnityEngine.Rect listRect, UnityEngine.Rect visibleRect) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.Rect visibleRect) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditorInternal.ReorderableList.DoList (UnityEngine.Rect rect) (at <97436df440ca462884c5332c1d8ebbe7>:0)
AYellowpaper.SerializedCollections.Editor.SerializedDictionaryInstanceDrawer.DoList (UnityEngine.Rect position) (at Assets/Plugins/SerializedCollections/Editor/Scripts/SerializedDictionaryInstanceDrawer.cs:124)
AYellowpaper.SerializedCollections.Editor.SerializedDictionaryInstanceDrawer.OnGUI (UnityEngine.Rect position, UnityEngine.GUIContent label) (at Assets/Plugins/SerializedCollections/Editor/Scripts/SerializedDictionaryInstanceDrawer.cs:106)
AYellowpaper.SerializedCollections.Editor.SerializedDictionaryDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Assets/Plugins/SerializedCollections/Editor/Scripts/SerializedDictionaryDrawer.cs:55)
UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, System.Boolean includeChildren, UnityEngine.GUILayoutOption[] options) (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEditor.UIElements.PropertyField.<CreatePropertyIMGUIContainer>b__44_0 () (at <97436df440ca462884c5332c1d8ebbe7>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <9d7fc877145d4138982bf12cdd3484c6>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Error occures even when clicking "+" symbol to add an entry, as well as trying to look at Inspector in runtime. No errors when empty. Functionality seems to be working though.

Similar usage syntax, but less complex, like this, is drawn fine:

    [SerializeField, SerializedDictionary("ID", "Value")]
    private SerializedDictionary<string, string> metaData = new SerializedDictionary<string, string>();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions