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:
- GetName() value, when auto generated, can change run over run. In my tests development and shipping builds actually had differently generated names.
- If you do change name in editor than that stays the same run over run.
- GetFName() returns same value but as FName.
- GetFullGroupName() returns level by default.
- 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 returnStaticMeshComponent /Script/Engine.Default__DefaultPawn:MeshComponent0
. - Actors have HumanReadableName() method which currently just returns GetName().
- Actors have GetDebugName(actor) method which currently just returns actor.GetName() if actor != nullptr.
- 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.
- There is
UKismetSystemLibrary::GetDisplayName()
which returns label in editor mode otherwise owner.GetName() + component.GetName(). - 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.