Download

UMG - Create Buttons dynamically

Hi!

I want to build an inventory.
The Items have an Array of Enums called “ItemActions” like “Use”, “Equip”, “Combine” etc.
I want to create Buttons dynamically. So that only the Actions of the current Item are on the screen.

Is there smooth way to do this?

Yeah, use Canvas Panels, Vertical Boxes or Horizontal Boxes, make sure they’re set to Is Variable (top of details panel on the right with the widget component selected) so they can be accessed in the event graph.

Then use the “add child” node for that panel/box. Make a widget “UMG_ItemInfo” that displays various text strings. Then in the event graph for your main hud do a for each inventory item, create widget UMG_ItemInfo and update all the text strings from your inventory item stats array/struct.

Is there a possibility to “bind” this function to the current selected Item?

I don’t know how far are you with your inventory but i started yesterday and found really useful tutorial that might help you in many ways. It’s not exactly what you are looking for but well… see for yourself if you are interested https://www.youtube.com/watch?v=2Ot5udsHFVw

Well you must have a variable or an index that points to which item is currently selected. Myself I created a menu like ARK’s system with a scrollbox and items in it, where I could add right click for options etc. Works like charm.

Is this a correct setup? It does work, but I’d like to bind this function to the variable itself, not call the Dispatcher event with a function that changes the variable.