Add component to actor in C++ (the final word!)

Hello everyone, is there solution for UE 5.2?
I still could not make component shows in editor window. It created, shows in viewport, but unclickable and dont shows in editor panel.

There is one of variant of code I used to make it work

USkeletalMeshComponent* SkeletalMeshComponent =
NewObject(
Actor,
USkeletalMeshComponent::StaticClass());

// We register the skeleton resource (which is not meant to be transient to
// the engine).
SkeletalMeshComponent->SetSkeletalMesh(SkeletalMesh);

// We register the components and attach them to the editor
// We are adding at runtime so its necessary to manually register to the engine.
SkeletalMeshComponent->AttachToComponent(
Actor->GetRootComponent(),
FAttachmentTransformRules::KeepRelativeTransform);

// Manually called because the component won’t appear in the list without this
// call.
Actor->AddInstanceComponent(SkeletalMeshComponent);

// Registration is required at runtime since we don’t add during construction
SkeletalMeshComponent->RegisterComponent();

Component creation called in actor during PreInitializationComponent

1 Like