UMG property bindings does not work on derived widgets in cooked builds

Greetings, i’ve encountered a bug with UMG property bindings in cooked builds.

Steps to reproduce :

  1. Create empty blueprint project.
  2. Create new UserWidget and place some Text inside of it.
  3. In level blueprint create instance of this widget and add it to viewport on BeginPlay event.
  4. Bind a function to Text’s Text property with a value of “some text from parent”.
    [ If you make cooked build on this stage, it will work fine ]
  5. Derive a new child widget by creating new UserWidget and reparenting it to our previously created widget.
  6. Override GetText function that is binded to our Text in parent widget with “some text from child”.
  7. Delete all child slots (there is Canvas by default) from derived widget.
  8. In level blueprint change blueprint class of widget we are adding to our derived class.
  9. Cook and package your build and then launch. You will see binding is not working at all and our Text shows default value of “TextBlock” (by default).

I am also having this issue with my blueprints, they widget is created and added to viewport on begin play in my player controller. the text in the widget is bound to functions which read functions and return a string equivalent. odd thing is my Month value which is based of an Enum just returns “MonthNames_MAX”. works perfectly fine inside the editor and i cant remember making any changes which would cause any different behavior in the widget. First noticed in 4.17, have since upgraded to 4.18 and can confirm i am still having this issue.

Building for Windows (64-bit) and have tried nativizing assets etc, making changes to build settings. nothing seems to work.

I do have some widgets where values are reading correctly. I will try to figure out the differences between them and post any news if i find any.

Ok so after some investigation. I found that the ui elements that were behaving weirdly all had functions bound where the value is retrieved based of a local variable (to the widget). When i tried changing the default value of the variable and then building i found that the default value (even though it should have been changed inside the widgets initialization) was the value being shown (not the default value of the text or proper return from the bound function).

What i also found were the elements in the same widget whose values were based of variables inside another blueprint entirely (in my example, gamestate) would work properly

Found out it was an issue with my Interface (which i use to dispatch events instead of an event handler) was for some reason running before my ui was created (i think) which made the binds default to the variables default value.

In order to fix it i changed to Event Dispatchers and when the widget is created i just call a function to set all the variables to what i want them to be, the event dispatcher then updates them as needed.

Not sure if this will solve your issue but it solved mine

I made a similar decision but placed my functional on Tick within derived classes. That was temporal fix.

I made a research and i suppose its cooking bug. Looks like for derived widgets with no subwidgets inside (because unnecessary due to parent widgets) are saved with RootWidget variable set to nullptr in WidgetTree. So when we are loading widget in coocked build its not initialized, because supposed to have everything already loaded from package. (see UWidgetBlueprintGeneratedClass::InitializeWidgetStatic() function ). So there is more reasons to believe this is bug.

Hello RoyalWing,

We are using a new bug submission form. Please navigate to the link below for more information.

Link: Unreal Engine Bug Submission Form - Announcements - Epic Developer Community Forums

Make it a great day