I want to set a random value (say between 1-10) to the text on a button. This value has to change every time the widget is loaded. How can I achieve this?
I tried doing something along those lines, but the text value keeps fluctuating when I try to run it
In the details of the text button, there is a bind function. You can just set that to RandomIntInRange.
Yes, you need to do it on one of the button states ( I can’t recall them all now ), like ‘moused over’, or during construction.
This value has to change every time
the widget is loaded.
Can you specify what that means? Loaded? As in when the widget is created?
Loaded, yes. The idea is the make the player select one of 4 options which keep changing everytime this widget is loaded on screen.
Sorry for being unclear. But I will be showing/hiding an existing widget and I want the values to change every time it is shown.
Hook up the above to a custom event and call it when you show the widget.
This is still quite unclear. There’s no such thing as Loading widgets on screen - this has no meaning in UE4. Can you clarify?
Are you going to be creating a new widget every time? Or simply showing / hiding an existing widget? It’s generally just this:
You may want to call it when the widget is Constructed / Initialised. Or call it via a custom event when you believe it needs updating.