Updating Widget Components Inside the Editor - Guide

Hey there,

In this guide I will show you how to update widget components inside of the editor. Usually this doesn’t work inside the construction script because any changes you make to the widgets content will be lost. Only after you press play it will display properly.
The solution is to have a delay between running the construction script and updating the widget. Because the widget will be recreated after the construction script is run and any changes will be lost. (At least I think that is what happens)

Guide:

  1. I create a new widget and add a text to it. Don’t forget to set it as a variable.

  2. Create a new blueprint with the parent set to widget component.

  3. Inside the Widget Component under class defaults set the widget to the widget from step 1.

  4. Create a new custom event (“Update Widget”). In this we will have the Delay and then set the content of the widget.

  5. I will create a variable the display text and expose it (Eye Icon) so that can I later change it inside the level.
    UnrealEditor_118

  6. Now I will add the widget component to the actor. And inside the construction script I will call the update widget event from step 4.

  7. Now when I place this inside the Level I can change the text variable and it will update inside the editor.

Enjoy!

Now you can use your own widget setup with it. The only important part is that you keep the delay before your code which sets the widget content. The delay is placed inside a component and not the construction script actor because a delay doesn’t work there inside the editor.
When I disconnect the delay it wil show the default text again.

4 Likes

I guess this will work for any component, not only widgets. I struggled with something similar a couple of years ago. There are other workarounds but that delay node seems neat.

Delay Until Next Tick is a UE5 only thing, right?

Have read a bit into it “This is how it has to work since instance component transforms aren’t applied till after actor construction is reran.” Sounds like the fix should also work for them. Have to test it later.

I don’t know when delay till next tick was added, at the end is the same as a delay with 0 but looks a little bit cleaner.

2 Likes

Have tested it and yes it does work! For anyone interested here is the universal setup which should work with any components and actors:

  1. I made an actor component with an event “Start delayed construction” which makes after an delay an interface call back to the parent “Return Delay”. (I tested it with component event dispatcher but they don’t seem to work inside the editor.)

  2. Inside the actor I call on construct “Start delayed construction”

  3. Now I add the Interface and add the construction logic which doesn’t work usually. In this example getting component transforms and setting the length of an arrow component.

Result:
It will print the correct transform


and will change the arrow length
UnrealEditor_131

Its actually kinda sad how easy the fix is :sweat_smile:

Disclaimer: Keep in mind that there is probably a reason delay doesn’t work inside the construction script. But in my experience I didn’t encounter any problems, if you encounter any feel free to share.

3 Likes

unreal engine 5.1.1 on custom widget compoent create event after save file ,will crashFatal error!

Unhandled Exception: EXCEPTION_ACCESS_VIOLATION writing address 0x000000000000006e

0x00007ffe669c7bf3 UnrealEditor-Core.dll!UnknownFunction []
0x00007ffe6656757f UnrealEditor-CoreUObject.dll!UnknownFunction []
0x00007ffe662b2fbf UnrealEditor-CoreUObject.dll!UnknownFunction []
0x00007ffe662b045f UnrealEditor-CoreUObject.dll!UnknownFunction []
0x00007ffe66469bc4 UnrealEditor-CoreUObject.dll!UnknownFunction []
0x00007ffe66467ec3 UnrealEditor-CoreUObject.dll!UnknownFunction []
0x00007ffe6646787b UnrealEditor-CoreUObject.dll!UnknownFunction []
0x00007ffe628466d8 UnrealEditor-Engine.dll!UnknownFunction []
0x00007ffe62938aab UnrealEditor-Engine.dll!UnknownFunction []
0x00007ffe628d1475 UnrealEditor-Engine.dll!UnknownFunction []
0x00007ffe5eb2f706 UnrealEditor-UMG.dll!UnknownFunction []
0x00007ffe63ce543c UnrealEditor-Engine.dll!UnknownFunction []
0x00007ffe63d0a2ca UnrealEditor-Engine.dll!UnknownFunction []
0x00007ffe603d606b UnrealEditor-UnrealEd.dll!UnknownFunction []
0x00007ffe603d305f UnrealEditor-UnrealEd.dll!UnknownFunction []
0x00007ffe6038a7c7 UnrealEditor-UnrealEd.dll!UnknownFunction []
0x00007ffe5dacbee3 UnrealEditor-Kismet.dll!UnknownFunction []
0x00007ffe5da6304a UnrealEditor-Kismet.dll!UnknownFunction []
0x00007ffe5da62d90 UnrealEditor-Kismet.dll!UnknownFunction []
0x00007ffe60393f8e UnrealEditor-UnrealEd.dll!UnknownFunction []
0x00007ffe5dba35dd UnrealEditor-Kismet.dll!UnknownFunction []
0x00007ffe5dbbf99c UnrealEditor-Kismet.dll!UnknownFunction []
0x00007ffe68950b21 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe68a61b87 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe68a3a0c4 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe68ae08d6 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe68b06a73 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe6889a508 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe6887ffca UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe688e6863 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe688d5343 UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffe688cafec UnrealEditor-Slate.dll!UnknownFunction []
0x00007ffecf8419a2 UnrealEditor-ApplicationCore.dll!UnknownFunction []
0x00007ffecf8267d1 UnrealEditor-ApplicationCore.dll!UnknownFunction []
0x00007ffecf844391 UnrealEditor-ApplicationCore.dll!UnknownFunction []
0x00007ffecf81ff93 UnrealEditor-ApplicationCore.dll!UnknownFunction []
0x00007ffef2f89e67 USER32.dll!UnknownFunction []
0x00007ffef2f89a56 USER32.dll!UnknownFunction []
0x00007ffe22e695f9 InkObj.dll!UnknownFunction []
0x00007ffedf601118 atlthunk.dll!UnknownFunction []
0x00007ffef2f89e67 USER32.dll!UnknownFunction []
0x00007ffef2f88690 USER32.dll!UnknownFunction []
0x00007ffecf845849 UnrealEditor-ApplicationCore.dll!UnknownFunction []
0x00007ff7fc347332 UnrealEditor.exe!UnknownFunction []
0x00007ff7fc36287d UnrealEditor.exe!UnknownFunction []
0x00007ff7fc36296a UnrealEditor.exe!UnknownFunction []
0x00007ff7fc365680 UnrealEditor.exe!UnknownFunction []
0x00007ff7fc3771b4 UnrealEditor.exe!UnknownFunction []
0x00007ff7fc37a516 UnrealEditor.exe!UnknownFunction []
0x00007ffef3153db1 KERNEL32.DLL!UnknownFunction []
0x00007ffef3f132a1 ntdll.dll!UnknownFunction []

Crash in runnable thread StallDetectorThread

Could you explain a bit more how you get the crash?
“unreal engine 5.1.1 on custom widget compoent create event after save file”
What do you mean with after save file?

LIFESAVER!

Thank you!

1 Like