RealDocs

FName::GetPlainNameString

function Core Since 4.0
#include "UObject/NameTypes.h"
Access: public

Description

Returns the name string without its numeric suffix as a dynamically allocated FString. Use when you need the base name independently of any instance number.

Caveats & Gotchas

  • This allocates a new FString each call. In tight loops or performance-sensitive code, prefer the in-place overload GetPlainNameString(TCHAR(&OutName)[NAME_SIZE]) to avoid heap allocation.
  • The returned string does not include the trailing underscore-and-number that ToString() appends. For example, an FName constructed as "Mesh_3" will return "Mesh" here.
  • The [[nodiscard]] attribute means the compiler will warn if you call this and discard the result — it's a signal that the allocation is not free.

Signature

[[nodiscard]] CORE_API FString GetPlainNameString() const

Return Type

FString

Example

Strip the instance number to find the asset base name C++
FName ActorName = SomeActor->GetFName(); // e.g. BP_Enemy_2
FString BaseName = ActorName.GetPlainNameString(); // "BP_Enemy"
if (UClass* AssetClass = FindObject<UClass>(nullptr, *BaseName))
{
    // Match found without the instance suffix
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.