void FName::AppendString(FString& Out) const { const FNameEntry* const NameEntry = GetDisplayNameEntry(); NameEntry->AppendNameToString( Out ); if (GetNumber() != NAME_NO_NUMBER_INTERNAL) { Out += TEXT("_"); Out.AppendInt(NAME_INTERNAL_TO_EXTERNAL(GetNumber())); } }
const FString& AActor::GetActorLabel() const { // If the label string is empty then we'll use the default actor label (usually the actor's class name.) // We actually cache the default name into our ActorLabel property. This will be saved out with the // actor if the actor gets saved. The reasons we like caching the name here is: // // a) We can return it by const& (performance) // b) Calling GetDefaultActorLabel() is slow because of FName stuff (performance) // c) If needed, we could always empty the ActorLabel string if it matched the default // // Remember, ActorLabel is currently an editor-only property. if( ActorLabel.IsEmpty() ) { // Treating ActorLabel as mutable here (no 'mutable' keyword in current script compiler) AActor* MutableThis = const_cast< AActor* >( this ); // Get the class UClass* ActorClass = GetClass(); // NOTE: Calling GetName() is actually fairly slow (does ANSI->Wide conversion, lots of copies, etc.) FString DefaultActorLabel = ActorClass->GetName(); // Strip off the ugly "_C" suffix for Blueprint class actor instances UBlueprint* GeneratedByClassBlueprint = Cast<UBlueprint>( ActorClass->ClassGeneratedBy ); if( GeneratedByClassBlueprint != nullptr && DefaultActorLabel.EndsWith( TEXT( "_C" ) ) ) { DefaultActorLabel.RemoveFromEnd( TEXT( "_C" ) ); } // We want the actor's label to be initially unique, if possible, so we'll use the number of the // actor's FName when creating the initially. It doesn't actually *need* to be unique, this is just // an easy way to tell actors apart when observing them in a list. The user can always go and rename // these labels such that they're no longer unique. { // Don't bother adding a suffix for number '0' const int32 NameNumber = NAME_INTERNAL_TO_EXTERNAL( GetFName().GetNumber() ); if( NameNumber != 0 ) { DefaultActorLabel.AppendInt(NameNumber); } } // Remember, there could already be an actor with the same label in the level. But that's OK, because // actor labels aren't supposed to be unique. We just try to make them unique initially to help // disambiguate when opening up a new level and there are hundreds of actors of the same type. MutableThis->ActorLabel = DefaultActorLabel; } return ActorLabel; }