Problem with ItemActions

Hi,

Long story short I was able to remove an item from my inventory that has a non-removable category thro QuantityDrop item action

The setup:

ItemAction that goes on All and has an exception category Non-Removable

Syringe - inherits All
Quest item - inherits All and Non-Removable

First time I open the inventory I press on Quest Item and I see an empty item action UI (keep in mind I removed the 2 buttons that are there by defaul cause i prefer to instantiate) - I think this should not happen its literally showing empty UI

Then I click on Syringe - I see 2 btns Remove and Cancel

Then I click on Quest item again and boom I see Remove and cancel. Now pressing Remove doesnt do anything but I swear once it did and it did remove the quest item.

Possible solution : Dont even show that Ui on Non-Removable categories.
 
There is an option on the not open the panel if there is no action available for that item:
1682061907374.png

The fact that it shows up the option to remove the quest item is odd. Perhaps there a bug somewhere. But I can't seem to be able to reproduce. it.

The Feature scene "12 Equipping" showcase a similar use case. Instead of "Remove" it's equip. So try to compare to see if that help you identify the issue.


I made a change to the code it shouldn't really change anything though:

In the ItemViewSlotsContainerItemActionBindingBase.cs replace those 3 functions.

Code:
/// <summary>
/// Open the item action panel.
/// </summary>
/// <param name="itemInfo">The item info selected.</param>
/// <param name="index">The index.</param>
protected virtual void OpenItemAction(ItemInfo itemInfo, int index)
{
    var itemViewSlot = m_ItemViewSlotsContainer.GetItemViewSlot(index);
    
    // Must refresh actions to check if the item has item actions.
    RefreshItemActions(itemInfo);
    
    if (CannotOpenItemActionPanel(itemInfo)) {
        NotifyCannotOpenPanel(itemViewSlot);
        return;
    }
    m_ActionPanel.AssignActions(m_ItemActionListSlice, itemInfo, m_ItemUser, m_ItemViewSlotsContainer, index);
    if (m_ItemViewSlotsContainer.Panel == null) {
        Debug.LogWarning("Parent Panel is not set.");
    }
    m_ActionPanel.Open(m_ItemViewSlotsContainer.Panel, itemViewSlot);
}
protected virtual void NotifyCannotOpenPanel(ItemViewSlot itemViewSlot)
{
    m_OnCannotOpenPanel?.Invoke();
    for (int i = 0; i < itemViewSlot.ItemView.Modules.Count; i++) {
        if (itemViewSlot.ItemView.Modules[i] is IItemActionBindingItemViewModule module) {
            module.OnCannotOpenItemActionPanel(this);
        }
    }
}
/// <summary>
/// Can the item action panel be opened.
/// </summary>
/// <param name="itemInfo">The item info.</param>
/// <returns>True.</returns>
protected virtual bool CannotOpenItemActionPanel(ItemInfo itemInfo)
{
    if (m_ActionPanel == null) { return true; }
    if (m_DisableActionOnEmptySlots && (itemInfo.Item == null || itemInfo.Amount <= 0)) { return true; }
    if (m_PreventOpenWhenNoAction && m_ItemActionListSlice.Count == 0) { return true;}
    return false;
}
 
I think what happens is that when I click on the Quest Item after I click on the Syringe (that has a remove) it removes the Syringe, so its still targeting the last item that has these 2 options. I still dont know why it spawns an empty UI the first time I click on the Quest Item tho
 
Top