Given this class (Skipping over UCLASS()
and etc. macros for simplicity):
class AContainer : AActor {
UPROPERTY()
TArray<AActor*> actors;
}
I want to be able to spawn specific actors and add them to the array. Eg.
AActor* a = GetWorld()->SpawnActor<AActor>();
a->AttachRootComponentToActor(this);
actors.Add(a);
And I want these actors to be editable in the editor. So if I place my AContainer
actor onto the stage, it would automatically come with children actors.
Is this possible? I’ve tried putting the spawn code inside the constructor, PostInitializeComponents()
, and PostInitProperties()
, but I always get a crash upon opening the editor because the level doesn’t yet exist within the world.