Then I have several classes, inherited from class A. In the Content folder I created UMG widgets and set those classes as the base classes for the widgets. In each of those widget I set the WidgetClass property to the respected widget class.
Also, in class A I have an overrided PostInitProperties() method, which is copying WidgetClass var to a static array. At some point in the game I’m accessing this array to create the widgets.
Now, if I open the widgets in the editor and then start playing, everyting works OK. But if I restart the editor and start playing without opening the widgets, my array stays populated with nullptrs.
It seems, that when PostInitProperties() fires for the first time, the value of the WidgetClass property is not initialized. And only if I open the widgets in the editor, the PostInitProperties() fires again and my array becomes populated with correct values.
Could you post the overloaded code used for PostInitProperties in your class? When you mention opening the widgets are you referring to open the widget blueprint for editing? Additionally when is the function being called in your class? According to the documentation (AActor::PostInitProperties | Unreal Engine Documentation) it is called after the constructor so if used inside the constructor it would be expected that not everything has been initialized yet. Instead you may want to try calling it on BeginPlay() or elsewhere in the code.
Are you referring to overloading or overriding the PostInitProperties() function? If you are overriding the function did you include the keyword “override” when declaring the function inside your class? Could you post the code showing the header and source file for your class?
If you just luanch the project and enter play mode, test UMG widget (a button) won’t be added, as the WidgetClass var will be null. An if you open the UMG blueprint for edit and then enter play mode again — it will show up.
Thanks for the test project, I understand what you’re seeing know. It appears this bug has already been reported (UE-12854) and should be fixed in a future update to the engine.