Download

Spawn buttons inside of an UMG widget

Hello folks,

how do i spawn dynamic buttons inside an UMG widget?

Lets say i loop through an array of alphabetical chars and create a button for each index.
Actually i would create a second UMG widget which just contains a button and a text as child of the button and then spawn and manipulate an instance of this second UMG widget for each array index.
But is there also a way to skip this second UMG widget and doing it all in one single widget?

All functions that i’ve found always need an instance or object reference.

Hope somebody could help me. :smiley:

  1. Create a widget blueprint - lets call it Button with text
  2. delete the canvas component in it
  3. Add a button with a text child component
  4. Go to the graph part of the widget and create a string variable - let’s name it ButtonText
  5. Go to the text child of the button in the designer view and where you change the text for it, there’s a small binding button click it and bind it to your ButtonText string variable
  6. When you want to create a dynamic button use the “Create widget” node and add it as a child to a slot component (Horizontal or Vertical box for example)
  7. If you want to change the text, simple drag of the widget variable from “Create Widget” node and change the ButtonText variable

Hope that helps, it isn’t as long as it seems, just needs a bit of preparing.

Oh sorry missed out an important step, for widget sizing, make sure you make it ‘DESIRED’ so it dynamically resizes as it needs to when you make an instance of it.

Okay i think my question got missunderstood. :slight_smile:

So here are some example Screenshots.

UMG Widget - Player Name Creator - Event Graph

&stc=1

UMG Widget - Player Name Creator - Designer View

02.png&stc=1

UMG Widget - Player Name Creator - CreateKeyboard Function

&stc=1

UMG Widget - Player Name Creator Button - Designer View

04.png&stc=1

UMG Widget - Player Name Creator Button - Event Graph

&stc=1

My original question was: Is there a way to spawn button objects dynamicly without reference?
In this case. Can i edit the createKeyboard function to spawn button objects without creating instances of Player Name Creator Button widget?

Hope this helps a bit more to understand my question.

Sorry for my bad english :frowning: