UEnum GetEnumText does not return DisplayName anymore

Since version 4.10 the GetEnumText return the enum as Text and not the DisplayName.

Having the following enum definition.

/** @brief Equipment types. */
UENUM(BlueprintType)
enum class EKEquipmentType : uint8
{
	ET_Undefined	UMETA(DisplayName = "Undefined"),
	ET_OneHand		UMETA(DisplayName = "1-Hand"),
	ET_TwoHand		UMETA(DisplayName = "2-Hand"),
	ET_OffHand		UMETA(DisplayName = "Off-Hand"),
	ET_Head			UMETA(DisplayName = "Head"),
	ET_Shoulders	UMETA(DisplayName = "Shoulders"),
	ET_Neck			UMETA(DisplayName = "Neck"),
	ET_Wrists		UMETA(DisplayName = "Wrists"),
	ET_Hands		UMETA(DisplayName = "Hands"),
	ET_Finger		UMETA(DisplayName = "Finger"),
	ET_Torso		UMETA(DisplayName = "Torso"),
	ET_Waist		UMETA(DisplayName = "Waist"),
	ET_Legs			UMETA(DisplayName = "Legs"),
	ET_Feets		UMETA(DisplayName = "Feets")
};

This function

inline FText UKAttributeHelper::GetEquipmentTypeEnumAsText(EKEquipmentType EnumValue)
{
	const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, TEXT("EKEquipmentType"), true);
	if (!EnumPtr)
		return DKT_GEN_INVALID;

	auto index = EnumPtr->GetIndexByValue((uint8)EnumValue);
	return EnumPtr->GetEnumText(index);
}

returns the type.
If I call the function with EKEquipmentType::ET_Head it returns “ET_Head” and not “Head”. It was not the case in previous versions.
I’ve check the source code and the code for returning the DisplayName is conditionned with preprocessor WITH_EDITOR.

FText UEnum::GetEnumText(int32 InIndex) const
{
#if WITH_EDITOR
	//@todo These values should be properly localized [9/24/2013 justin.sargent]
	FText LocalizedDisplayName = GetDisplayNameText(InIndex);
	if(!LocalizedDisplayName.IsEmpty())
	{
		return LocalizedDisplayName;
	}
#endif

	return FText::FromString( GetEnumName(InIndex) );
}

Is there another way to get the DisplayName ?

Txs for your help,
D.

As far as I can tell that #if WITH_EDITOR define has existed since UEnum::GetEnumText was first added back in 2013.

Unfortunately meta-data doesn’t exist in non-editor builds, so if you want display names for your enums outside of the editor you’ll have to do that manually.

Use GetDisplayNameTextByIndex ().. here is an example:

*.cpp

const UEnum* EnumPtr = FindObject(ANY_PACKAGE, TEXT(“SomeName”), true);
FText Name;
if (EnumPtr)
Name = EnumPtr->GetDisplayNameTextByIndex(InteractableType);

*.h

UENUM()
enum SomeName{
FILE1 UMETA(DisplayName = “somefilename1.txt”),
FILE1 UMETA(DisplayName = “somefilename2.txt”),
};


UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = “INTERACTABLE”)
TEnumAsByte InteractableType;

Thank you for the hint.
I’ve changed the architecture for this particular problem.
If I need it again, I will use this method.

Guys would you know why after uploading my game to Google Play the game wont display Score text anymore. If I install the shipping version from desktop folder Google services Leaderboard, achievements, add mob all work fine reading and writing to leader board. What does Google Play change after it’s been upload to them. Sorry guys I have no place to turn for these since I need some brain power here.