How do I set the display name of an actor from C++

The Rename method does not seem to work, any ideas? I want to set the name as it’s shown in the Scene Outliner.

I’m doing the following but the result is always “Box Brush” in the outliner and not my rename.

ABrush* newBrush = World->GetBrush();
newBrush->SetActorLocation(BaseBrush->GetActorLocation());
newBrush->Rename(TEXT("My New Name"));

UCubeBuilder* cubeBuilder = Cast<UCubeBuilder>(GEditor->FindBrushBuilder(UCubeBuilder::StaticClass()));
cubeBuilder->X = CubeSize.X;
cubeBuilder->Y = CubeSize.Y;
cubeBuilder->Z = CubeSize.Z;
cubeBuilder->Build(World, newBrush);

GEditor->Exec(World, TEXT("BRUSH ADD"));

How do you determine if its working or not? If cha ge name in PIE and go back to editor, changes will be reverted. We use rename in our app and it works like it should.

I updated my question with the code I’m using to show that it’s not getting renamed. What are you referring to when you say “PIE”?

PIE = Play in Editor, only moment when Scene Outliner is updating according to your code, or else you do things in class constructors.

Actually my code runs in PostEditChangeProperty, I’m not seeing an appropriate constructors with my code above where I can set name.

Hi there,

Maybe a bit late (just a bit) for your answer. If you want to modify the name located in the Scene Outliner
you should try using:

AActor::SetActorLabel( const FString& NewActorLabel );

This worked for me.

Other way is using arrows:

 ACameraActor* TPCamera = ()->SpawnActor<ACameraActor>(Location, Rotation);
    TPCamera->SetActorLabel(FString("TPCamera"));

SetActorLabel also asks me for a pointer to my UObject, strange that you’re able to use it without.