What is the return of AActor::GetName()?

I did a bit of the survey to figure out all kind of methods available to get name of actor or component. Here are few notes:

  1. GetName() value, when auto generated, can change run over run. In my tests development and shipping builds actually had differently generated names.
  2. If you do change name in editor than that stays the same run over run.
  3. GetFName() returns same value but as FName.
  4. GetFullGroupName() returns level by default.
  5. GetFullName(true) returns full unique name. For example, for pawns it would return MyCppPawn /Game/FirstPersonCPP/Maps/UEDPIE_0_FirstPersonExampleMap.FirstPersonExampleMap:PersistentLevel.MyCppPawn10 and for StaticMeshComponent it would return StaticMeshComponent /Script/Engine.Default__DefaultPawn:MeshComponent0.
  6. Actors have HumanReadableName() method which currently just returns GetName().
  7. Actors have GetDebugName(actor) method which currently just returns actor.GetName() if actor != nullptr.
  8. Actors have ActorLabel property and GetActorLabel() but both of which is editor only which means your code will fail to compile if you tried to package a shipping build with that call.
  9. There is UKismetSystemLibrary::GetDisplayName() which returns label in editor mode otherwise owner.GetName() + component.GetName().
  10. As the autogenerated names are not stable, current recommendation is to either explicitly name things in editor OR use tags on actor which can be checked using ActorHasTag(name) method.
8 Likes