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

To make the instanced component appear in the tree, you can do this instead of manually re-selecting the actor:

SelectedActor->AddInstanceComponent(NewComponent);

// Broadcast edit notifications so that level editor details are refreshed (e.g. components tree)
FLevelEditorModule& LevelEditor = FModuleManager::LoadModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
LevelEditor.BroadcastComponentsEdited();
2 Likes