I want to show a component in both the editor and game. I am using the following code to create my components and attach them. But the component appears only in game when I register them. If I dont register them then they appear only in editor.
UMyComponent* component = NewObject<UMyComponent>(this, UMyComponent::StaticClass());
component->SetWorldTransform(someTransform);
component->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepWorldTransform);
// If I comment the below code it show up in editor. If the below code is left uncomment then it shows up in game
if (GetWorld()) {
traffic_light->RegisterComponent();
}