Hi everyone,
Hopefully this question is simple enough:
I’m trying to create an editor tool for a project that allows for new components to be added on to an actor outside of the construction script.
The actor exists in the level and the user can press a button to add on components to the object in the level. After finished I need to be able to save this object in the level so that those components remain next time I load that level.
I’m trying to work out what the correct method of instantiating those components is, so far I’ve tried:
AttachedComponent = NewObject<UAttachedComponent>(this);
AttachedComponent->CreationMethod = EComponentCreationMethod::Native;
AttachedComponent->OnComponentCreated();
AttachedComponent->RegisterComponent();
AttachedComponent->SetupAttachment(RootComponent);
AttachedComponent->InitialiseComponent();
for a USceneObject called after PostInitializeComponents. However the components don’t appear on the object, and also don’t save as I get this error: Can-t-Save-graph-is-linked-to-private-objects — ImgBB
I’ve tried using CreateDefaultSubobject, which works fine, but only works during the constructor, which isn’t ideal for my use case since I need to be able to add/remove components during the editor.
Any help or advice would be massively appreciated, as I’m hitting a dead end with this.
Thanks,
Tim