Download

Adding widget buttons to an array not possible?

I’ve been trying to find a way to add buttons to an array but nothing seems to be working. I’ve placed a button into the event graph and prompted it to a variable. I converted the variable to an array but it doesn’t allow me to add buttons to that array. I want to create a main menu level selector and looping through the buttons and setting them unlocked or locked based on if the previous level is complete. However it’s just a pain to hard code it every time I want to add a new level so if anyone can help it would be much appreciated.

You are creating widgets, then you store references to them (from blue pin at node that created it).

And generally for dynamic gui in blueprints, You should make small\simple widgets as separate classes. In your case it should be just button with some button logic behind (like communicating with rest of game). Then you create dynamically that widget instead of creating just simple buttons and hooking communication to them.

If you want to progress beyond the most elementary interface, you’d need to take the advice Nawrot is giving here - wrapping a button (or another native element) in a User Widget ensures a lot of flexibility in the long run. Do note you can *still *add those User Widgets manually in the Designer as per usual - but each of them can now have a separate graph with its own functionality. [HR][/HR]
Apart from that, if you just want to keeps buttons in an array:

Annotation-20191212-082719.png

Funny. I think we basically all use the same idea with widgets and arrays :stuck_out_tongue:

for OP:
create a widget called WP_button where WP stands for WidgetPart or similar.
shove a button and text in it. Expose the text variable and make it so it gets applied during construction.

Then you can call in that widget instead of a button. With some (or a lot in my case) of work you can get the new widget instance to function exactly as you need for your needs and actually replace the default widget button.
I assume a lot of marketplace stuff would do this, but I’m also about to release my own version of it…