ValueDropdown with null entry raises exception

Issue #400 resolved
Former user created an issue

I have a ValueDropdown using a method that returns a ValueDropdownList<> using a MonoBehaviour, and I want the first entry in the value dropdown to be "null", so I add one item like this:

list.Add("Static Position", null);

this gives the following error:

NullReferenceException: Object reference not set to an instance of an object
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Odin Property Path: _steps.$0.#Settings.#b
Odin Drawer Chain:
> BoxGroupAttributeDrawer.
[Exception] NullReferenceException: Object reference not set to an instance of an object
Rethrow as OdinPropertyException: This error occurred while being drawn by Odin.
Odin Property Path: _steps.$0.#Settings.#b
Odin Drawer Chain:
> BoxGroupAttributeDrawer.

IValueDropdownEqualityComparer.GetHashCode()    <dbfdb55c3389430497486ef8f6b9c521>:0

System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert()    <f826c2584fc94ec19a48a6576640bdc5>:0

System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item()    <f826c2584fc94ec19a48a6576640bdc5>:0

ValueDropdownAttributeDrawer.ReloadDropdownCollections()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/AssetListAttributeOnSingleObjectDrawer.cs:182

ValueDropdownAttributeDrawer.Initialize()    <dbfdb55c3389430497486ef8f6b9c521>:0

OdinDrawer.Initialize()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:243

InspectorProperty.GetActiveDrawerChain()    <dbfdb55c3389430497486ef8f6b9c521>:0

InspectorProperty.Draw()    <dbfdb55c3389430497486ef8f6b9c521>:0

BoxGroupAttributeDrawer.DrawPropertyLayout()    <dbfdb55c3389430497486ef8f6b9c521>:0

OdinDrawer.DrawProperty()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368

InspectorProperty.Draw()    <dbfdb55c3389430497486ef8f6b9c521>:0

Debug.LogException()

InspectorProperty.Draw()

BoxGroupAttributeDrawer.DrawPropertyLayout()

OdinDrawer.DrawProperty()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368

InspectorProperty.Draw()

CompositeDrawer.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

NullableReferenceDrawer`1.DrawPropertyLayout()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/QuaternionDrawer.cs:62

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

ReferenceValueConflictDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

ReferencePathConflictDrawer`1.DrawPropertyLayout()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:64

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

FixUnityNullDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

ReferenceDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

PropertyContextMenuDrawer`1.DrawPropertyLayout()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:83

OdinDrawer.DrawProperty()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368

InspectorProperty.Draw()

CollectionDrawer`1.DrawItem()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/ColorDrawer.cs:90

CollectionDrawer`1.DrawItems()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/ColorDrawer.cs:77

CollectionDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

NullableReferenceDrawer`1.DrawPropertyLayout()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/QuaternionDrawer.cs:62

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

ReferenceValueConflictDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

ReferencePathConflictDrawer`1.DrawPropertyLayout()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/ValueDropdownAttributeDrawer.cs:64

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

FixUnityNullDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

ReferenceDrawer`1.DrawPropertyLayout()

OdinDrawer.CallNextDrawer()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/MemberSerializationInfo.cs:32

PropertyContextMenuDrawer`1.DrawPropertyLayout()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/OnValueChangedAttributeDrawer.cs:83

OdinDrawer.DrawProperty()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Utilities/PersistentContext/PersistentContextCache.cs:368

InspectorProperty.Draw()

InspectorUtilities.DrawPropertiesInTree()    F:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Windows/SerializationDebugger/SerializationInfoMenuItem.cs:27

PropertyTree.Draw()

OdinEditor.DrawTree()

OdinEditor.DrawOdinInspector()

OdinEditor.OnInspectorGUI()

GUIUtility.ProcessEvent()

Comments (4)

  1. Dominic Antonelli

    I have the same issue. For now, I'm using a workaround by replacing null with a dummy instance, that I compare against elsewhere instead of doing "== null".

  2. Bjarke Elias

    Hey, I believe I've solved the issue with the modifications made from your previous issue @dominicatkearnstech. I'm unable to reproduce the issue on my end at least.

    A snippet that reproduces the issue on your end would be really helpful to verify whether the fix works.

    Thanks!

  3. Dominic Antonelli

    Hi Bjarke. It was really just the same snippet as above: list.Add("Some Label", null) added to a ValueDropdownList<MyType> would throw the exception whenever "Some Label" is selected from the dropdown.

  4. Log in to comment