Dynamically create skeletal meshes in editor

Hi,

I’m creating an actor component that adds a feature of “modular” character into any UCharacter that takes data from UDataAsset with module definitions. It works ok for most part except the meshes disappears after I click the compile button on the actor (the owner of the component).

Is there a way to make it so that they stay after I hit compile?

What I’m doing is:

  1. In the actor component I have a set of properties that allow me to select modules
  2. In the PostEditChangeProperty I call a function to update the owner’s skeletal mesh according to selection
  3. I’m attaching the new USkeletalMeshComponents to owners skeletal mesh (I do first clear them and destroy the components that are already there)

The code that create each of the actual sub-skeletal mesh components:

  USkeletalMeshComponent* SubMesh = NewObject<USkeletalMeshComponent>(GetOwner());
  SubMesh->RegisterComponent();

  SubMesh->SetSkeletalMeshAsset(ModuleSkeletalMesh);
  SubMesh->AttachToComponent(GetOwner()->GetMesh(), FAttachmentTransformRules::KeepRelativeTransform);
  SubMesh->SetLeaderPoseComponent(GetOwner()->GetMesh());

My understanding is that the skeletal mesh components that I create via NewObject are “lost” when the actor got recreated (when the Compile happens). But then there should be a way to reinitialize that after for in-editor view.