AsyncFuncActionPanelInt with Icons

Hi there!

What would be the best way to show item icons (and not just the item name) with the AsyncFuncActionPanelInt that is used with the Assign to Hotbar Item Action? I added in a item view slot, item view, and item icon view to the Item Action Button prefab, but in looking at the code I would need to create some custom methods to allow for this. I was playing around with it but running into some trouble with it calling several other methods. Is there a simpler way to do this?

Screen Shot 2022-03-19 at 1.34.54 PM.png

Thanks!
 
Unfortunatly there isn't an easy way to do this. But your use case seems like something a few people would want so I made a change, hopoefully it works. The way you want.

Find the new AssignHotbarItemAction script attached below.

This change required a new public property on this class:
Code:
/// <summary>
/// A base class to create asynchronous actions in a panel.
/// </summary>
/// <typeparam name="T">The type of the action parameter.</typeparam>
public abstract class AsyncFuncActionsPanel<T> : DisplayPanel
{
    [Tooltip("The action button prefab. Requires an ActionButton component.")]
    [SerializeField] protected GameObject m_ActionButtonPrefab;
    [Tooltip("The parent for the buttons.")]
    [SerializeField] protected Transform m_ButtonParent;
    protected List<ActionButton> m_ItemActionButtons = new List<ActionButton>();
    protected LayoutGroupNavigation m_LayoutNavigation;
    protected IList<AsyncFuncAction<T>> m_Actions;
    protected bool m_WaitForInput = true;
    protected T m_ValueToReturn;
    protected bool m_Canceled;
    public bool Canceled => m_Canceled;
    public T ValueToReturn => m_ValueToReturn;
    public List<ActionButton> ItemActionButtons => m_ItemActionButtons;
    public LayoutGroupNavigation LayoutNavigation => m_LayoutNavigation;
    public IList<AsyncFuncAction<T>> Actions => m_Actions;

Now that "ItemActionButtons" is public I can access it in the AssignHotbarItemAction script and assign the itemInfos of the ActionButtons if they are ItemViewSlots.

Do let me know if that helps. If so I'll add this change to the next update
 

Attachments

  • AssignHotbarItemAction.cs
    6.5 KB · Views: 5
Top