C++ UENUM in BluePrint "Enum to String" Returns different values in Android/Windows

If you have a C++ UENum with a DisplayName set

UENUM(BlueprintType)		//"BlueprintType" is essential to include
enum class EVictoryEnum : uint8
{
        VE_Dance 	UMETA(DisplayName="Dance"),
        VE_Rain 	UMETA(DisplayName="Rain"),
	    VE_Song	UMETA(DisplayName="Song")
};

Running in PIE the String conversion works as expected (Dance, Rain, Song). However If you run on Android or Windows you get the code name instead of the display Name, (VE_Dance, VE_Rain, VE_Song)

So If I wanted to display string representation of an enumeration on the screen I need to write my own Enum To String Map and conversions myself? instead of relying on the automatic blueprint conversions “Enum To String”

Hey -

The reason for this difference is because the meta data is stripped out of shipping builds, so the behavior you’re seeing here is expected. The DisplayName is mainly meant to help organize / reference the parts of the enum in the editor.

Cheers

If you want to print what is set as the UMETA(DisplayName) then you would need to create your own way to do so, yes. Alternatively, you can rename the enum values in code to whatever name you would like displayed using the EnumToString node.

For any one looking to do this, DO NOT follow this example as it also uses Code based string representations of the enumerations vs user friendly representation like display_name

Thanks for the very fast response, of course enum names are restricted from having characters like spaces or conflicting with keywords so this mean writing my own conversions.

It would be nice if the “Enum To String” conversion had a tooltip or something explaining its behavior is different in debug mode vs deployment. While I understand the reasoning for it, its very confusing behavior for a developer. Especially since its an auto-conversion.

The Description for “Enum to String” is “Returns user friendly string for enumerator” I think that description is not accurate and should be updated as the string returned for the enumerator is not user friendly always.

2 Likes

I found solution for myself, that might works for you all as well.
I’ve added underscore ‘_’ in each of my enum value where spacebar ’ ’ is required.
Then in my blueprint I use Unreal Engine’s “Enum to String” function and after that I use function “Replace” of FString class.