[Bug]Hotbar item is still displayed in hotbar even if I throw it out from inventory

Justus

Member
My UIS version is v1.2.13

If the item is apple, display apple with count 0 is no problem.
But when the item is a weapon, it's abnormal.
We may need some option to control this behavior in different situaltion.

I need a behavior that when comsumables comsumed out and when weapon has been dropped or broken, the Hotbar will remove the item from itself as we had never assign it to hotbar
 
Last edited:
I'm adding this to the next update. for the ITemHotbar script

Code:
[Tooltip("If true the items removed from the inventory will be removed from the hotbar")]
[NonSerialized] protected bool m_RemoveItemIfAmountIs0;




protected virtual void RefreshItemSlotInfos()
{
    var slots = m_ItemViewSlots;
    for (int i = 0; i < m_ItemViewSlots.Length; i++) {
        var itemInfo = slots[i].ItemInfo;
        if (itemInfo.Item == null) { continue; }
        var amount = itemInfo.ItemCollection?.GetItemAmount(itemInfo.Item) ?? 0;
        ItemInfo newItemInfo;
        if (amount == 0) {
            var result = itemInfo.Inventory?.GetItemInfo(itemInfo.Item);
            if (result.HasValue) {
                newItemInfo = result.Value;
            } else {
                newItemInfo = (0, itemInfo);
            }
        } else {
            newItemInfo = (amount, itemInfo);
        }
        if (m_RemoveItemIfAmountIs0 && newItemInfo.Amount == 0) {
            slots[i].SetItemInfo(ItemInfo.None);
        } else {
            slots[i].SetItemInfo(newItemInfo);
        }
    }
}
 
Top