Assigning an item to the hot bar will be done even if I choose to cancel.

misottyo

New member
Hello. Thank you for the wonderful assets.

When I try to assign an item to the hotbar in the item action, even if I select "Cancel", it is assigned to the first column.

If I chose to cancel again, the assignment was toggled empty.

This happens when you select the item action "Toggle Assign".

This is the case even in the default state of the demoscene, but can you confirm it in that environment as well?

And what are the possible solutions?

version of unity
2021.1.21f1

UIS version
1.2.2
 
You are right this is a bug. Thank you for bringing this to my attention.

To fix it I had to make a few small changes to some a few scripts:

AsyncFuncActionsPanel is the one I changed the most so I attached the file bellow

In AsyncFuncActionsPanelInt I added:
C#:
/// <summary>
/// The cancel value is -1;
/// </summary>
/// <returns>-1</returns>
protected override int GetCancelValue()
{
    return -1;
}

And in AssignHotbarItemAction I changed:

Code:
/// <summary>
/// Invoke action after waiting for index slot.
/// </summary>
/// <param name="itemInfo">The item.</param>
/// <param name="itemUser">The item user (can be null).</param>
/// <param name="awaitedValue">The index slot.</param>
protected override void InvokeWithAwaitedValue(ItemInfo itemInfo, ItemUser itemUser, int awaitedValue)
{
    if (awaitedValue == -1 || m_AsyncFuncActionPanel.Canceled) {
        return;
    }
    if (m_ToggleAssign) {
        m_ItemHotbar.ToggleAssignItemToSlot(itemInfo, awaitedValue);
    } else {
        m_ItemHotbar.AddItem(itemInfo, awaitedValue);
    }
}

Essentially previously the AsyncFuncActionsPanel wasn't updating the returned value on cancel and it wasn't saying that it was cancelled, so it simply returned the last pressed index (by default zero) when canceld.
I've now added a way to define the Cancel value (I made it -1 for int by default) and added a boolean getter for when the action was cancelled.

I'll make sure to include this in the next update which should be very soon
 

Attachments

  • AsyncFuncActionsPanel.cs
    4.6 KB · Views: 1
Top