How to update a bind variable on the editor in UMG?

I made a new UMG Widget that is just a simple Button with a Text Block inside.

http://puu.sh/lNxs7/bdbd831d58.png

The Text of the Text Block is bind to a variable that is publicly editable.

http://puu.sh/lNxzX/405a581764.png

http://puu.sh/lNxDX/503eef0d3f.png

So when I implement this new button widget on my main menu, I can just change that variable to change the text.

http://puu.sh/lNxLq/2bcce78259.png

Doing this will correctly change the button text in-game as expected.

http://puu.sh/lNxOI/79a03f2f6a.jpg

Screenshot from the game running

But it still doesn’t change the text on the button in the editor.

http://puu.sh/lNxV2/94374b9737.png

Is there any way I can make the bind variable update live in the editor? I even tried updating the variable on its Event Construct, but that doesn’t update in the editor either.

1 Like

Hello,

When you created the binding, as well as the variable that you’d like to use to change your text, did you go into your GetText function and connect your Button Text to the return node on that function? Here is an example of how I’ve set mine up, and the text is changing as intended:

Are you sure it updates both on the button widget and in the parent widget? I tried setting it up exactly like yours, but it still has the same problem. It updates correct on my button widget. But on my Menu widget that instances the new button widget. That doesn’t updates in the editor (but updates correctly in game).

The Menu widget not updating: link text

Button widget updating correctly: link text

In my test project, adding the widget containing the Text Block to another widget updated the text in both cases. It wouldn’t update in the editor because the value is not being updated until the game is played and the GetText() function is called.

It wouldn’t update in the editor

So yours also doesn’t update in the editor just like mine? And there’s no way around that? Maybe some way to force the GetText() function to be called in the construction script or something?

The construction script is called when an instance of that widget is being constructed in the level, which would unfortunately not update it in the editor.

This thread is a bit older, but here is the answer I just stumbled uppon when looking up the same problem.

regards

Edit: After one day of work with the solution in the link, I came to a new problem using this methode. It does work, at least for what it is supposed to do, update stuff within the editor. But OnSynchronizeProperties() (see link) is also called at least once when the widget is created.This will call what ever it should Syncronize, e.g. the text of a TextBox. But the TextBox->SetText() function call will break the binding on the TextBox.Text. This is also stated in the documentation: Drive UI Updates with Events | Unreal Engine Documentation (at the bottom). Other property bindings keep working. A quick fix would be adding OnTick() to the parent class and call OnSynchronizeProperty() within the tick and thus would emulate the binding to a variable. This is to often? Bindings get called once or twice a tick anyway, see: Question on UMG binding's update - Blueprint Visual Scripting - Unreal Engine Forums

Not sure if this is good practice but for me, the solution was to explicitly set the properties of the widgets I wanted to see updated in the editor during pre-construct.

This is not perfect though as for some reason it will also prevent the binding to be changed at runtime. Use this only for properties you care to set up during the construction phase.