[BUG] Dragging and dropping an already equipped item to the equipment slot deletes that item. Also any other item after that gets deleted...

_aL

New member
1. Create a new project with Unity 2022.2.14
2. Download and install Ultimate Inventory System 1.2.15.
3. Equip an item from the inventory and then drag and drop the same item to the equipment slot again while it is already equipped. The item disappears and any other items equipped in that slot afterwards also disappear.

Console Error message: "The ItemSlotCollection stack target cannot be null."

Video:




debug.png
 
Thank you for bringing this to my attention
I made a few changes to the ItemSlotCollection in the past two releases and it seems I missed that.

I added a condition to avoid adding an item that is already in the collection in that index.

In the ItemSlotCollectionView.cs script

Code:
/// <summary>
/// Can the item be added to the item view slot.
/// </summary>
/// <param name="itemInfo">The item info.</param>
/// <param name="index">The index.</param>
/// <returns>True if the item can be added.</returns>
public override bool CanAddItem(ItemInfo itemInfo, int index)
{
    var canAddBase = base.CanAddItem(itemInfo, index);
    if (canAddBase == false) { return false; }
    if (Inventory.CanAddItem(itemInfo, m_ItemSlotCollection) == null) { return false; }
    
    //Check if the item you are trying to add isn't already in this collection at that index:
    if (itemInfo.ItemStack == GetItemAt(index).ItemStack && itemInfo.Item.ID == itemInfo.ItemStack.Item.ID) {
        return false;
    }
    return true;
}

Let me know if you have any other issues
 
  • Like
Reactions: _aL
Top