C++ Deferred construction of UObject with parameters / initial setup?

I know new Actors can be spawned using:
World->SpawnActorDeferred
Which will allow me to set some public properties on them before finalizing the spawn process.

However, I want to do this on UObjects as well and have full access to private properties (if possible) before finalizing the spawn process. Is this possible?
Or am I limited to implementing my own setup method for almost every object I create?

Best,
Seda145

You can declare the class doing the work as a friend class for your custom UObject class.

Doing that will allow you to customize all private members of the new object from within the manipulator class’ methods.

Thank you, this is exactly what I needed.

Is it also possible to set up the properties on the UObject before it runs its constructor?
Or pass the parameters to the constructor through NewObject()?
Take for an example an inventory system, where the inventory creates a few items:

Inventory:

UItem* NewItem = NewObject<UItem>();
NewItem->SomePrivateProperty = SomeValue;
// NewItem->FinalizeConstruction() ???

You cannot pass custom parameters to UObject-derived constructors. This includes actors. Deferred spawning does not “delay” the constructor since that is impossible.

Deferred Actor Spawning just delays script construction and component initialization until you call FinishSpawning()

You can only use an exist UObject or Asset of same base type as a template.
Example:

UItem* NewItem = NewObject<UItem>( this, NAME_None, RF_NoFlags, BaseItemAssetPtr );

Whatever values are in the base Asset/Object, goes as default value for the newly created item instance. If your Ptr is to a Class / BP class, you must pass as a template its classPtr->GetDefaultObject() to the NewObject<> method.

thank you