What would I enter for "TCHAR * EnumPath"

I’ve noticed a few UEnum methods ask for EnumPath ie:

static FString GetValueAsString
    const TCHAR * EnumPath,
    const T EnumValue

(From: UEnum::GetValueAsString | Unreal Engine Documentation)

What exactly does that syntax look like?? There is literally nothing I can find that explains this.


TCHAR * is the Inner Type of FString

Hi there!

You can just make an FString and use the FString::Operator* to access the FString’s inner data type which is TCHAR*!

FString YourPath = "Your Happy Path Now That You Read This";




Ok that makes more sense, but is this specifically for returning the enum’s path, and is that like a harddrive path? Is it related to the object inheritance of the enum (like UObject?) Thanks again for your time!

Is this one of the unsolved mysteries of the unreal programming universe?

In many cases this path fits with the following template – “ClassName.EMyEnumType”. But in some cases it doesn’t work. For example:

UEnum::GetValueAsString(TEXT("MyGameMode.EModeExampleEnum"), EGameModeExampleEnum::FIRST)); //it works
UEnum::GetValueAsString(TEXT("MyPlayerController.EControllerExampleEnum"), EControllerExampleEnum::FIRST)); //it works
UEnum::GetValueAsString(TEXT("MyCharacter.ECharacterExampleEnum"), ECharacterExampleEnum::FIRST)); //it crashes

If you look inside the GetValueAsString method, you will see how it works:

UEnum* EnumClass = FindObject<UEnum>(nullptr, EnumPath);
UE_CLOG(!EnumClass, LogClass, Fatal, TEXT("Couldn't find enum '%s'"), EnumPath);
return EnumClass->GetEnumText(Value);

This way to find enum pointer isn’t good for any case. So the best way to find pointer and get enum value as string is:

const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("ECharacterExampleEnum"), true);
if (EnumPtr)
	auto EnumName = EnumPtr->GetEnumName((int32)ECharacterExampleEnum::FIRST);



Awesome, that totally makes sense now, thanks for your time!