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 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.