bsimser / Inventory-Pro

https://devdog.io
MIT License
2 stars 0 forks source link

Odin cannot inspect InventoryItemBase objects stored in ScriptableObject arrays #290

Open bsimser opened 5 years ago

bsimser commented 5 years ago

Original report by Garret Polk (Bitbucket: GarretPolk, GitHub: GarretPolk).


I created a ScriptableObject that contains an array of InventoryItemBase objects. When I try to assign an item to this collection in the Editor I get a NullReferenceException in Inventory Pro from Odin.

[Exception] NullReferenceException: Object reference not set to an instance of an object
InventoryItemBase.Equals()    Assets/Devdog/InventoryPro/Scripts/Items/InventoryItemBase.cs:737

InventoryItemBase.Equals()    Assets/Devdog/InventoryPro/Scripts/Items/InventoryItemBase.cs:732

Sirenix.Utilities.TypeExtensions+<>c__25`1[T].<GetEqualityComparerDelegate>b__25_3()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.Utilities/Extensions/TypeExtensions.cs:558

Sirenix.OdinInspector.Editor.PropertyValueCollection`1[TValue].set_Item()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueCollection.cs:350

Sirenix.OdinInspector.Editor.PropertyValueEntry`1[TValue].SmartValueReferenceSet()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:712

Sirenix.OdinInspector.Editor.PropertyValueEntry`1+<>c__DisplayClass27_0[TValue].<DelayedSmartValueReferenceSet>b__0()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/Value Entries/PropertyValueEntry.cs:702

Sirenix.OdinInspector.Editor.PropertyTree`1[T].InvokeDelayedActions()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:1621

Debug.LogException()

PropertyTree`1.InvokeDelayedActions()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:1625

InspectorUtilities.EndDrawPropertyTree()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Misc/InspectorUtilities.cs:247

PropertyTree.Draw()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:304

OdinEditor.DrawTree()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:93

OdinEditor.DrawOdinInspector()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:233

OdinEditor.OnInspectorGUI()    X:/Repositories/sirenix-development-framework/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:85

GUIUtility.ProcessEvent()

My fix is to add a null check in InventoryItemBase.cs Equals() operator at line 736

if (other == null)
    return false;