PostInitProperties not working with UMG property

I have a class (let’s call it A), that is derived from UUserWidget. In this class I have the following property:

UPROPERTY(EditAnywhere, BlueprintReadOnly, NoClear, Category = "GUI")
TSubclassOf<class UUserWidget> WidgetClass;

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.

I’ve already rewrote a lot, so it’s hard to remember the exact code in the overloaded function, but it was smthing trivial like:


For opening the widgets I meant opening the widget blueprint for editing, yes.

The function was being called at the BeginPlay() or later.

Hey Elringus-

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.


Doug Wilson

Hey Elringus-

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?

Oh, sorry, I misstyped: it’s override, not overload. And yes, I did include the keyword.

Though I’ve already done what I needed some other way, I’ve made a repro project with this bug: GitHub - Elringus/PostInitUMGBug: Repro project for the PostInitProperties bug in UE4

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.

Hey Elringus-

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.


Doug Wilson