PostInitProperties() :: how to call a BlueprintNativeEvent?

I try to invoke a BlueprintNativeEvent in my object’s PostInitProperties(), but a strange behaviour occurs.


void Atest::PostInitProperties()
//this should trigger
mesh = NewObject(this,UStaticMeshComponent::StaticClass());
//but this triggers instead
mesh = NewObject(this,USkeletalMeshComponent::StaticClass());
//declared as UFUNCTION(BlueprintNativeEvent, BlueprintCallable) in Test.h
bool Atest::initAsStatic_Implementation()
D(“initAsStatic in c++”) //my macro to printString in editor.
return true;

The above C++ class has a BP child, with this override:


As you may have noticed, no matter the default C++ _Implementation or the override, both return true and print some string to indicate they run, but on practice no string is printed and false is returned from initAsStatic() at line4.
i assume that false is returned because it is the default return value of empty bool functions.

The function works well if triggered from BeginPlay or during regular runtime though. why is it not working in PostInitProperties()?

Because at this stage object and even more actor and it’s blueprint scripting is not fully initiated, not to mention it’s called in editor when you place actor in editor. Blueprint is meant to run only in game play, so earliest event you can use is BeginPlay, optionally OnConstruction which should behave the same as construction script. Outside of those events things may work strange if at all