Problem creating equipment window with Item View Slots

pleska

New member
I have been working on creating an equipment view and I think I have everything setup the same way as the demo with just a different UI and Item View Slots Container for the Equipment but as I run I get this error and my one equip item doesn't show up.

IndexOutOfRangeException: Index was outside the bounds of the array.
Opsive.UltimateInventorySystem.UI.Views.ViewDrawerBase.RemoveBox (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:146)
Opsive.UltimateInventorySystem.UI.Views.ViewDrawer`1[T].DrawView (System.Int32 boxIndex, System.Int32 elementIndex, T element, System.Boolean removePreviousBox) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:237)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainer.AssignItemToSlot (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Int32 slot) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainer.cs:60)
Opsive.UltimateInventorySystem.UI.Panels.Hotbar.ItemSlotCollectionView.Draw () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/Hotbar/ItemSlotCollectionView.cs:218)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase.HandleInventoryUpdate () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:341)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase.SetInventory (Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory inventory, System.Boolean handleChange) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:288)
Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainerBase.SetInventory (Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory inventory) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainerBase.cs:266)
Opsive.UltimateInventorySystem.UI.Panels.ItemViewSlotContainers.ItemViewSlotsContainerPanelBinding.OnInventoryBound () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ItemViewSlotContainers/ItemViewSlotsContainerPanelBinding.cs:78)
Opsive.UltimateInventorySystem.UI.Panels.ItemViewSlotContainers.InventoryPanelBinding.BindInventory (Opsive.UltimateInventorySystem.Core.InventoryCollections.Inventory inventory) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ItemViewSlotContainers/InventoryPanelBinding.cs:71)
Opsive.UltimateInventorySystem.UI.Panels.ItemViewSlotContainers.InventoryPanelBinding.BindInventory () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ItemViewSlotContainers/InventoryPanelBinding.cs:51)
Opsive.UltimateInventorySystem.UI.Panels.ItemViewSlotContainers.InventoryPanelBinding.Initialize (Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel display) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ItemViewSlotContainers/InventoryPanelBinding.cs:36)
Opsive.UltimateInventorySystem.UI.Panels.ItemViewSlotContainers.ItemViewSlotsContainerPanelBinding.Initialize (Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel display) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ItemViewSlotContainers/ItemViewSlotsContainerPanelBinding.cs:37)
Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel.Setup (Opsive.UltimateInventorySystem.UI.Panels.DisplayPanelManager manager) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanel.cs:129)
Opsive.UltimateInventorySystem.UI.Panels.DisplayPanelManager.SetupDisplayPanels (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanelManager.cs:123)
Opsive.UltimateInventorySystem.UI.Panels.DisplayPanelManager.SetPanelOwner (UnityEngine.GameObject panelOwner) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanelManager.cs:154)
Opsive.UltimateInventorySystem.UI.Panels.DisplayPanelManager.Initialize (System.Boolean force) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanelManager.cs:112)
Opsive.UltimateInventorySystem.UI.Panels.DisplayPanelManager.Awake () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanelManager.cs:72)

Hierarchy of Window in the canvas is

Panel w/ DisplayPanel, DisplayPanelSelector, ItemViewSlotsContainerPanelBinding,
- PanelContent
-- Equipment Item View Slot Container w/ ItemSlotCollectionView, ItemViewSlotDragHandler, ItemViewDropHandler, ItemViewDrawer
--- Item View Slots Content
---- Equipment (Rect Transform Only)
----- EquipSlots (Rect Transform Only)
------ Left (a Grid Layout Group)
------- Equip Slot (Head) w/ ItemViewSlot, ItemViewSlotCategoryRestriction
-------- Equipment Slot Item View w/ ItemView, IconItemView, DragOffView, DragHoverIconPreviewItemView and the Image for background of slot
--------- Slot Icon w/ Image
--------- ColorFillter w/ Image
-------- (Repeating more times of EquipSlot down)
------- And then repeat of right side equipment and middle equipment

Note: My player has in Inventory component an Equipment ItemSlotCollection that is Purpose Equipped assigned to the same ItemSlotSet I am using in the Equipment Item View Slot Container. Right now it has one item in the same ItemCategory as the Equip Slot (Head)

So any idea where I should look, I have been staring at this for a while.

Thanks,
 
I could be wrong but I believe the issue is that Left Right and Middle gameobjects.
I believe that all the Item View Slots MUST be direct children of the View Drawer "content" (by default I think that's the EquipSlots transform).

Let me know if that fixes the issue (you'll need to place your slots manually...)
 
I am making progress but I am wondering if I am running into a design limitation. I broke my ItemSlotSet into 3 different definitions and moved redundant copies of ItemViewDrawer and ItemSlotCollectionView, etc. to each of the parent elements for the left, middle, and right equipment sets using the new 3 itemslotsets that my inventory now uses. Then I at the panel level I added 3 copies of the ItemViewSlots Container Panel Binding for each ItemViewSlots Container mapping it to the inventory and added them to the DisplayPanel bindings. But now 2 of my ItemSlotCollections are not being set with the Inventory at run time, only the first is. And I am getting some errors about the ItemSlotCollection x having a different itemslotset but everything seems mapped right. Is it not possible to use multiple ItemSlotCollections in one DisplayPanel today?

If so I will need to redesign my UI to not use grid layout groups.

But at least I am making progress as I do see the inventory slot fill.
 
Ah yes indeed... I didn't think about having multiple ItemSlotCollections within the same inventory for multiple Item View Slot Collections... That is a limitation. I'll add it to my list of things to investigate.

In the meantime there are two options for you.
1) Don't use the grid layout groups and instead place the slots manually
2) Implement a custom Item View Slot Container which doesn't use an Item View Drawer

I would recommend option 1 this way you can quickly get it working, and then in the future you can come back to it with a better solution, if required.
 
Thanks that solved my problem. I moved all of the Item View Slots out of the grid layout groups and gave their parent the access to the ItemViewDrawer and ItemSlotCollectionView and then went back to one ItemSlotSet and all my errors and warnings disappeared. It seems that when my hierarchy of looks like this...

Panel w/ DisplayPanel and ItemViewSlotsContainerPanelBinding (with the Item View Slots Container pointing to my "EquipSlots Game Object"
... any number of objects and levels here.
- EquipSlots w/ ItemSlotCollectionView, ItemViewDrawer, ItemViewSlotDragHandler, ItemViewDropHandler
-- Equip Slot (Head) w/ ItemViewSlot, ItemViewSlotCategoryRestriction
--- Equip Slot Item View w/ ItemView, IconItemView, DragOffView, DragHoverIconPreviewItemView
---- SlotIcon
---- ColorFilter
-- ... Repeating same set as the previous Equip Slot (for other armor and gear)

EquipmentSceneTree.png

Was the organization that works wonderful. I didn't have a combination like you said to put any levels between the EquipSlots that has the ItemViewDrawer and ItemSlotCollectionView and the various Equip Slot(s) that have the ItemViewSlot in them or everything breaks. Just so you know my use case was for different layout groups. The UI looks like this when done though. Layout groups just made the math easier but this works fine.

Equipment.png
 
I'm glad you got it working.
So I was thinking about it a bit more last night and realised you can have multiple ItemSlotCollection with a UI for each. You just need to point to it using its name.
1611306365541.png
If I were you I wouldn't change anything since you've already got it working. But I just wanted to let you know it is an option
 
Top