I have created an Actor Blueprint and a Widget Blueprint, in the Widget Blueprint I have a TextBlock in it (exposed as variable). I have added a WidgetComponent to the Actor blueprint, and when I update an exposed variable on the actor blueprint (which causes the construction script to run) the text in the Widget resets to the default value, and not the value that I have specified.
Does anyone know if this is an Unreal bug, or what I am doing wrong?
You’re definitely fighting a few things here. I would recommend staying away from, or relying on, the construction script to change the text of your widget component. Instead, try creating a variable in your widget bp to hold the text then on the PreConstruct event (in your widget bp) go ahead and SetText to whatever is held in this text variable. You should be then be able to set the value of the text field directly in your widget component under the details panel.
NOTE: When you add the new variable and make it instance editable you might need to refresh your widget component by selecting None and then reselecting your widget in the class dropdown of the widget component
Let me know if that doesn’t work out.
I have also tried this way but it does not change the text in the widget in the editor, the text stays at whatever it’s default value is.
The only way I can get it to change in editor is by doing the method shown in the pic above, but it will only update the text if I manually move the Actor blueprint in the level. If I then update the exposed variable again, the text will reset to its default.