Does UObject has a callback for when the "Construct Object from Class" is done?

Hi,

I have the following model:

UCLASS(BlueprintType, Blueprintable)
class MYSPACESHIPGAME_API UStarCluster : public UObject
{
	GENERATED_BODY()

private:
	
	UPROPERTY(BlueprintReadOnly, Category = "Stars", meta = (AllowPrivateAccess = "true", ExposeOnSpawn = "true"))
	FName Name;

	UPROPERTY(BlueprintReadOnly, Category = "Stars", meta = (AllowPrivateAccess = "true", ExposeOnSpawn = "true"))
	TArray<FStarData> Stars;
...

And I’m constructing it using “Construct Object from Class”.

image

Is there any method from the UObject interface called after this node finished? I found virtual void PostInitProperties(); but Stars and Name values are not set at this time yet.

Thanks in advance!
Mateus.

What problem are you trying to solve exactly? Return Value is a fully constructed instance of your class.

Are you trying to do something on your UObject similar to BeginPlay?

Oh, I’m sorry it was not clear.

Yes, I’m wondering if exists something like OnConstruction or BeginPlay for UObject that is called after the variables referenced on the “Construct Object from Class” node gets assigned. I would like to use them for performing calculations on the object without doing any callback after getting the returned constructed object.

Thanks for the reply!

Sadly not. For UObjects you’ve got to either call your own Init type function yourself, or wrap it in some other type of construction call like Widgets do. They are UObjects but have an OnConstruct callback built into how they are created by UMG.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.