B Bai New member Mar 20, 2025 #1 I want to display a specific attribute of an item in a pop-up window, for example: "Whether to use the 'Great Sword'". I know how to get the attribute value of an item through the manual, but I don't know how to get the currently clicked item. Attachments 屏幕截图 2025-03-20 223403.png 12.4 KB · Views: 11
I want to display a specific attribute of an item in a pop-up window, for example: "Whether to use the 'Great Sword'". I know how to get the attribute value of an item through the manual, but I don't know how to get the currently clicked item.
Sangemdoko Moderator Staff member Mar 21, 2025 #2 So I'm assuming you are using an ItemViewSlotsContainer (InventoryGrid, Hotbar, etc...) for your UI. These have a function OnItemViewSlotClicked So in an OnAwake or Start function you can listen to the event Code: m_InventoryGrid.OnItemViewSlotClicked += OnItemClicked; Then you can handle that however you want: Code: protected virtual void OnItemClicked(ItemViewSlotEventData slotEventData) { var item = slotEventData.ItemViewSlot.ItemInfo.Item; }
So I'm assuming you are using an ItemViewSlotsContainer (InventoryGrid, Hotbar, etc...) for your UI. These have a function OnItemViewSlotClicked So in an OnAwake or Start function you can listen to the event Code: m_InventoryGrid.OnItemViewSlotClicked += OnItemClicked; Then you can handle that however you want: Code: protected virtual void OnItemClicked(ItemViewSlotEventData slotEventData) { var item = slotEventData.ItemViewSlot.ItemInfo.Item; }