Hotbar drag&drop in main menu

ChristianWiele

Active member
Hi,

I would like to have a hotbar drag & drop target within my main menu (similar to the Equipment Item View Slot container in the demo). Is there any example available for this, or how do I get a reference to the hotbar from the Gameplay Panel?

Thanks, Christian
 
Unfortunatly there is no example of this. The main problem is that the hotbar saves the item stack to monitor directly in the UI component, so you cannot use two different hotbars (one in the gameplay the other in the main menu), without writing some custom code to sync them toghether.
A work around is to move the hotbar panel transform between the gameplay and the main menu panel with some custom code.

In the next update I will add many minimalist example scenes as requested by the community. One of those scenes will show how to use an equipment UI as a hotbar. That allows you to keep items in the hotbar in their own item collection, which mean you can have multiple UI in a few places and they automatically sync since they all monitor the same data.

You can get the Hotbar component through code using the Display Panel Manager to get its panel by name.
Code:
var panelManager = InventorySystemManager.GetDisplayPanelManager(m_DisplayPanelManagerID);
var hotbarPanel = panelManager.GetPanel(m_HotbarPanelName);
if (hotbarPanel == null) {
    Debug.LogError($"The Assign Hotbar Item Action could not find the panel named : '{m_HotbarPanelName}' .");
    return false;
}
var hotbar = hotbarPanel.GetComponentInChildren<ItemHotbar>();

You can have a look at the AssignHotbarItemAction for a more indepth example.

The next update is planned before the end of the month, sorry for the inconvinience
 
Top