DataAsset array result null during runtime

I have a problem with DataAssets class. Basically I have a C++ class that inherits from UDataAsset (lets call it DA_Test) and another class that inherits from UObject (lets call O_Test). The two classes are blueprintable so in the editor I have blueprints that inherits from DA_Test or from O_Test.

In the O_Test class I have an array of DataAssets variable written like this:

UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<DA_Test*> VarName;

My problem is that this variable works fine in the editor (I can populate the array with my custom DataAssets blueprint classes that ineriths from the C++ one). But when I instantiate the O_Test class, this array results null (I mean a length of 0), why this happen?

Im not instantiating O_Test with the ConstructObject function because I written a static function in my O_Test class to instantiate it with the NewObject C++ function.

I hope I have explained the question well :wink:

well, 1, if you’re calling a static function to instantiate the O_Test, you can’t really expect it to be an instance of your blueprint – it’s going to be an O_Test, not an O_Test subclass/blueprint . . . unless your constructor code is going out and finding the blueprint and instantiating it, i guess

second, even if you are doing that, how would you expect unreal to load the blueprint’s data into the object if you’re not using unreal’s constructor function?

This static function has an input of type TSubclassOf<O_Test> and it returns the object of type O_Test for example to save it in a variable. It is very similar to the ConstructObject function. But yes probably it is not the same thing. Now I have done a different approach and I’m not using DataAssets (only UObjects) and works very fine, so the problem seems to appear only with UDataAsset object.

However thank you for the answer

Okay sorry I am so stupid haha :wink: I found the solution from myself

My error was so simple: I was creating the UObject with my static function but I forgot that properties set in blueprint are processed in the PostInitProperties function. Using PostInitProperties all things work fine