I have created a Widget Blueprint (r-click in the Content Browser, selected Create Asset → User Interface → Widget Blueprint) and added some image and text widgets to it in the Designer section. I made sure it saved and compiled.
Then in my character, I create an instance of the widget and add it to the viewport (see screenshot).
When I run the game in the editor, I can see that something is getting added to my viewport - but it almost seems like it is a “cached” version (the very first version of the widget I made). No amount of saving or compiling seems to “update” the widget blueprint to the character – the character just keeps using this old version. Restarting the editor, re-compiling, re-running the level doesn’t fix this issue.
HOWEVER, when I simply double-click on the widget blueprint so that it opens in its own editor… then suddenly everything works fine and the character uses the latest version of the widget blueprint.
What am I doing wrong?
I am using UE version 4.6.1.
Since you’re assigning your newly created hud widget to “GameHUDWidget”, you should be adding that to the viewport instead of the return value of your created widget.
So break the link from AddToViewport and Create Widget, and instead Get GameHUDWidget for the AddToViewport.
Hope it helps!
Just tried that, but it doesn’t resolve the issue.
It shouldn’t matter if I’m getting a value from a variable or directly from a pin – but maybe I’m missing something. Can you explain why you thought this would have worked?
It was the way I read the wording to the problem, my apologies.
“it almost seems like it is a ‘cached’ version (the very first version of the widget I made).” this sounded to me like the problem was with the widget update after “Create Widget” rather than after physically designing the widget in blueprints.
Can you reproduce this issue in a completely blank new project?
Maybe you have another “My HUD” widget created and saved somewhere else in your files and it is referencing that one instead of the latest one?
Just tried, and I can reproduce it in a new project. Here are the steps I used to reproduce
- Created a new Third-Person Template,
- Created new “Widget Blueprint”, added an image and compiled and saved.
- Opened up the MyCharacter Blueprint and added the nodes shown above to the EventGraph, compile, save and run
Now the UI shows up as expected. However, if I then subsequently edit the Widget Blueprint, save and compile, and then close and re-open the project… I get the first version of the Widget Blueprint without the latest changes.
OK, this is unexpected … when I then move the code nodes above to the Level Blueprint, then the problem goes away and the latest version of the “Widget Blueprint” is always used. Does this mean there is something “special” about executing “Widget Blueprints” from the Level Blueprint – maybe some hang-over from the UDK days?
I followed your steps, everything works as intended, which leads me to believe something is locking your file after it is created?
Is your .uasset set to read-only?
I’m using 4.6.1 just like you, so, I’m not quite sure what else could be causing your blueprint widgets not to update/save properly.