Issue with ViewDrawerBase (Character Equip Window)

Hi,

I already wrote my problem in discord but you said that I should open a more dateiled Forum post, so here I am ;)
My problem is that when I open my Character Window I get this issue there:
IndexOutOfRangeException: Index was outside the bounds of the array. Opsive.UltimateInventorySystem.UI.Views.ViewDrawerBase.GetViewGameObject (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:168) Opsive.UltimateInventorySystem.UI.Views.ViewDrawerBase.RemoveView (System.Int32 index) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:148) Opsive.UltimateInventorySystem.UI.Views.ViewDrawer`1[T].DrawView (System.Int32 viewIndex, System.Int32 elementIndex, T element) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Views/ViewDrawer.cs:268) Opsive.UltimateInventorySystem.UI.Item.ItemViewSlotsContainer.AssignItemToSlot (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Int32 slot) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Item/ItemViewSlotsContainer.cs:62) Opsive.UltimateInventorySystem.UI.Panels.Hotbar.ItemSlotCollectionView.Draw () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/Hotbar/ItemSlotCollectionView.cs:220) Opsive.UltimateInventorySystem.UI.Panels.ItemViewSlotContainers.ItemViewSlotsContainerPanelBinding.OnOpen () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/ItemViewSlotContainers/ItemViewSlotsContainerPanelBinding.cs:95) Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel.OpenInternal () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanel.cs:305) Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel.Open (Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel previousPanel, UnityEngine.UI.Selectable previousSelectable, System.Boolean selectDefault) (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanel.cs:249) Opsive.UltimateInventorySystem.UI.Panels.DisplayPanel.Open () (at Assets/Opsive/UltimateInventorySystem/Scripts/UI/Panels/DisplayPanel.cs:227) MyStuff.Scripts.UI.CharacterWindowManager.showWindow () (at Assets/MyStuff/Scripts/UI/CharacterWindowManager.cs:128) MyStuff.Scripts.UI.InventoryWindowManager.showWindow () (at Assets/MyStuff/Scripts/UI/InventoryWindowManager.cs:38) MyStuff.Scripts.UI.CanvasManager.LateUpdate () (at Assets/MyStuff/Scripts/UI/CanvasManager.cs:20)

Also when I Drag&Drop the sword in the slot I will get the same failure:
1618251308607.png

After dropping this I get this:
1618251371532.png

Here are my settings:
1618251546048.png


I hope that this can help you finding out what is wrong there...
 
Here additional screenshots because Iam limit to 3 pictures per post....

Prefab of the Character-Window-Part:
1618251784204.png

ItemSlotSet which is used in the ItemSlotCollectionView
1618251819206.png

Main-Character:
1618251892219.png


I checked every Slot in the EqipmentItemViewSlotContainer prefab but every slot is filled correctly.
Can I send you something that you may debug it or something like that?
 
Are you using the latest version of UIS, v1.1.6?

looking at my code it seems you are accessing an index that does not exist.

I think I have pretty good idea what is not working. The system expects the Item View Slots to be in a flat hierarchy, All under the same parent. But you have it in groups Left Vertical, Middle Horizontal, Right Vertical.

The View Drawer gets the Item View Slots and assigns them an index depending on their child index. I will look into removing that restriction, but for now you can try to flatten your Item View Slots hierarchy to see if it fixes the issue.

1618301737001.png
 
Could you try replacing the initialize function of ViewDrawerBase in the ViewDrawer script by:

Code:
/// <summary>
/// Initialize the component.
/// </summary>
public virtual void Initialize(bool force)
{
    if (m_IsInitialized && !force) { return; }
    if (m_Content == null) { m_Content = transform; }
 
    var itemViewSlots = m_Content.GetComponentsInChildren<IViewSlot>();
    for (int i = 0; i < itemViewSlots.Length; i++) {
        var viewSlot = itemViewSlots[i];
        if (m_DisableViewSlotImageComponent) {
            viewSlot.DisableImage();
        }
        if (m_RemoveViewsOnInitialize) {
            RemoveChildrenFromTransform(viewSlot.transform);
        }
    }
    m_ViewSlots = itemViewSlots;
    if (m_DrawEmptyViewsOnInitialize) {
        for (int i = 0; i < m_ViewSlots.Length; i++) {
            DrawEmptyView(i, i);
        }
    }
    m_IsInitialized = true;
}

That should allow you to keep the hierarchy the way you have it now, I tested it quickly so let me know if you still run into issues after this fix
 
Top