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.
Create a widget blueprint - lets call it Button with text
delete the canvas component in it
Add a button with a text child component
Go to the graph part of the widget and create a string variable - let’s name it ButtonText
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
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)
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.
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.