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?
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:
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()
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.