The idea was OK when I had like 12 LVLs. Now, it’s 25, and I am heading to 50 and new functions are appearing, so I am trying to figure out, how not to spend a day copying the same stuff to all the button-click events.
Is there maybe a parrent-child relation? Like: create a parrent button and add this function for the button? Or how would you approach this situation? Like now, if I continue the old way, I will call the “change best time text” event by coping 25 times the call event to each button click, but is there a better way?
The easy solution seems to be Event Tick, but I am proud of not using it anywhere in my project so far…
I’m sure there’s an easier way to do this- reuse of widgets to fit many cases is pretty standard with UMG! I do think some more context might be in order- are these all separate buttons? Think- is there a way you would be able to make ONE button that might change its text or use based on an input from a parent widget?
On the top there are two packs of LVLs (pink, green).
You click one, it gives you a different list of levels to play.
The buttons I am talking about are the LVL buttons - in this case the pink ones:
Tutorial 1, Tutorial 2, etc.
When I click this LVL button, Play Selected Level changes to Play Tutorial 1, for example.
In the right of the picture, There is text saying Text Block.
This text will show the best time of a completed level stored in the Map variable.
Now, I am trying to call an update of the Text Block every time I click (select) a different level button. As mentioned before - each button click should trigger this action of updating the Best time text (because the level changes, so the text should change).
BTW: So far i created Event Timer and I run it every 0,1 sec and It works ok… But would be great for other use cases to have some code, that triggers every time any button is pressed.
make the button a custom widget, generate them on a for loop saving their index. on button pressed return the index ie 0,1,2,3. get that index from an array of levels that you set manually.
or if you need more details, use a for each loop from the array and pass through any dynamic details such as map name