So I’ve been getting a couple instances of this ArgumentNullException (almost) every time I try to change something basic (like the sprite icon) of an InventoryItem to something new. I get a few instances of this error in my console, but the game seems to otherwise work fine. Even if I change it back to an old sprite it still reocurrs. If I comment out the new line for slots[10] it still happens. But if I exit Unity and re-launch the errors is gone. If I again try to change the sprite, it happens again. If I exit and relaunch Unity the error is gone. Also - sometimes I’m lucky and the error doesn’t show up at all.
My guess is there’s some cache that’s not being refreshed when you change a scriptable object for an InventoryItem.
I think my workaround works but I’d still like to understand what’s going on.
code:
private void Awake()
{
slots = new InventoryItem[inventorySize];
slots[0] = InventoryItem.GetFromID("71e73607-4bac-4e42-b7d6-5e6f91e92dc4");
slots[1] = InventoryItem.GetFromID("0aa7c8b8-4796-42aa-89d0-9d100ea67d7b");
slots[10] = InventoryItem.GetFromID("0f368cbf-6818-4367-bbab-0a1ba8ba3bd5");
}
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
UnityEditor.SerializedObject.FindProperty (System.String propertyPath) (at <da771086bc2e4cfc9ad0a72e083a7f98>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindPropertyRelative (UnityEngine.UIElements.IBindable field, UnityEditor.SerializedProperty parentProperty) (at <8ad9ecbe25e14b10b6dde783af6e4aa2>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.BindTree (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <8ad9ecbe25e14b10b6dde783af6e4aa2>:0)
UnityEditor.UIElements.Bindings.SerializedObjectBindingContext.ContinueBinding (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedProperty parentProperty) (at <8ad9ecbe25e14b10b6dde783af6e4aa2>:0)
UnityEditor.UIElements.Bindings.DefaultSerializedObjectBindingImplementation+BindingRequest.Bind (UnityEngine.UIElements.VisualElement element) (at <8ad9ecbe25e14b10b6dde783af6e4aa2>:0)
UnityEngine.UIElements.VisualTreeBindingsUpdater.Update () (at <e66f217a64a747d48b478f0d70978704>:0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at <e66f217a64a747d48b478f0d70978704>:0)
UnityEngine.UIElements.Panel.UpdateBindings () (at <e66f217a64a747d48b478f0d70978704>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.UpdateSchedulers () (at <e66f217a64a747d48b478f0d70978704>:0)
UnityEngine.UIElements.UIEventRegistration.UpdateSchedulers () (at <e66f217a64a747d48b478f0d70978704>:0)
UnityEditor.RetainedMode.UpdateSchedulers () (at <8ad9ecbe25e14b10b6dde783af6e4aa2>:0)