NullReferenceException on Equipment Item View Slot Container

Theremy

New member
Hi,

So like I said in discord channel, I get a NullReferenceException error every time I select Equipment Item View Slot Container GameObject on the hierarchy after play.
I'm not sure what is wrong, maybe I accidentally delete or change something in scene but I have no clue. I attach the screenshot of my inspector settings for the ItemSlotViewCollection and the Inventory as well as the full error message.

I am not sure if this is related, but the equipped item doesn't disappear from the inventory view.

I am using Unity 2020.2.1f1 and I am still using UIS version 1.1.4.

*Sorry, It looks like I posted this thread twice by accident.

Code:
NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory.GetItemCollection (Opsive.UltimateInventorySystem.Core.InventoryCollections.ItemCollectionID collectionID) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/Inventory.cs:402)
Opsive.UltimateInventorySystem.UI.Panels.Hotbar.ItemSlotCollectionView.OnInventoryChanged (Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory previousInventory, Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory newInventory) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/Hotbar/ItemSlotCollectionView.cs:141)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase.SetInventory (Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory inventory, System.Boolean handleChange) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:286)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase.SetInventory (Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory inventory) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:269)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:252)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainer.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainer.cs:43)
Opsive.UltimateInventorySystem.Editor.Inspectors.ItemSlotCollectionViewInspector.InitializeInspector () (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/ItemSlotCollectionViewInspector.cs:49)
Opsive.UltimateInventorySystem.Editor.Inspectors.DatabaseInspectorBase.DrawInOrder (UnityEngine.UIElements.VisualElement parent, System.Boolean nested) (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/DatabaseInspectorBase.cs:45)
Opsive.UltimateInventorySystem.Editor.Inspectors.InspectorBase.CreateInspectorGUI () (at Assets/Opsive/UltimateInventorySystem/Editor/Inspectors/InspectorBase.cs:33)
UnityEditor.UIElements.InspectorElement.CreateInspectorElementFromEditor (UnityEditor.Editor editor, System.Boolean reuseIMGUIContainer) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.InspectorElement.Reset (UnityEditor.SerializedObject bindObject) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.InspectorElement.ExecuteDefaultActionAtTarget (UnityEngine.UIElements.EventBase evt) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <3cdf672c21b849dea215f9c9aff21f77>:0)
UnityEditor.UIElements.DefaultSerializedObjectBindingImplementation.SendBindingEvent[TEventType] (TEventType evt, UnityEngine.UIElements.VisualElement target) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.DefaultSerializedObjectBindingImplementation.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.UIElements.DefaultSerializedObjectBindingImplementation+SerializedObjectUpdateWrapper objWrapper, UnityEditor.SerializedProperty parentProperty) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.DefaultSerializedObjectBindingImplementation.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.BindingExtensions.Bind (UnityEngine.UIElements.VisualElement element, UnityEditor.SerializedObject obj) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.InspectorElement.AddToClassList (System.String className) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.EditorElement.Init () (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.UIElements.EditorElement.SetPanel (UnityEngine.UIElements.BaseVisualElementPanel p) (at <e020ad89c1af43769f98694c4076cf19>:0)
UnityEditor.EditorUIServiceImpl.CreateEditorElement (System.Int32 editorIndex, UnityEditor.IPropertyView iw, System.String title) (at <636901c1d182466493c5675b68aa6275>:0)
UnityEditor.PropertyEditor.DrawEditors (UnityEditor.Editor[] editors) (at <1e441e8684a14fe4b8f8a926d91afc3a>:0)
UnityEditor.PropertyEditor.RebuildContentsContainers () (at <1e441e8684a14fe4b8f8a926d91afc3a>:0)
UnityEditor.InspectorWindow.RedrawFromNative () (at <1e441e8684a14fe4b8f8a926d91afc3a>:0)
 

Attachments

  • Inventory-Inspector.PNG
    Inventory-Inspector.PNG
    20.9 KB · Views: 2
  • ItemSlotCollectionView-Inspector.PNG
    ItemSlotCollectionView-Inspector.PNG
    40.5 KB · Views: 2
  • UIS-EquipmentError-Hierarchy.PNG
    UIS-EquipmentError-Hierarchy.PNG
    10.9 KB · Views: 2
Last edited:
The code now is a bit different so it may have already been fixed.

You can add this condition in the ItemViewSlotsContainerBase script:
Code:
if (Application.isPlaying == false) {
    m_IsInitialized = true;
    return;
}

around line 163 at the top of the Initialize function. This will prevent all the events from being registered in edit mode.
Let me know if it fixes your issue. If it does I'll keep the change for the next update
 
Alright, it works!
Yay, Thanks!

FYI, I also manage to update the UIS to 1.1.5 in my project, and that error still appears if I don't add those lines to the script.
 
Top