Get display name from enum

Is it not possible to get the display name from an enum? I’m trying to use the enumerator as a place to store values about the character, Hair Color, Eye Color etc. and then I want to simply get the chosen value and display it to a widget but it seems that it’s not possible to get the display name from an enum which is really weird.

This is my enumerator:

And when I try to get display name there are no options:

3 Likes

You can simply cast it to string, that’ll result in the name you set in the enumeration editor.

6 Likes

Thanks for the suggestion. I tried converting it to a string and it wouldn’t. It said it was incompatible.

279465-untitled.png

2 Likes

Ahh that’s what happened. I tried to plug it directly into the Text portion of my widget and it gave an incompatible error. Converting to string and then to text fixed the issue. Thank you :slight_smile:

1 Like

This doesn’t solve the issue if you want FText returned as a type for localisation purposes.

SOLVED THIS ONE
I wanted to use a list I made in an enumerator (text only) and then use those values for socket names.

When in the blueprint and having access to the enumerator value I chose, I needed to:

  1. take the enumerator value
  2. convert it to a string
  3. convert the string to a name

It was the middle step (#2) that was the key.

4 Likes

> FText → FString is dangerous as it is a potentially lossy conversion for some languages.

Welcome to the party. Only 11 months late. Not bad :smile:

This is an old post but maybe it will help someone in the same situation.

When it comes to localization using ToString from an enum is of no help.

In the localization Dashboard there is an option to import Meta Data of Type Enum (from your C++ Code), however this is working in Editor only.

So the only viable option is to create a mapping between your Enums and a FText stored in a DataTable.

1 - For example you have a an Enum EClassType, which contains UMETA(DisplayName = “Warrior”) and UMETA(DisplayName = “Mage”).
2 - Create a Struct in Blueprint, name it S_DisplayName, the struct will contain a FText LocName.
3 - Now create a new Data Table, DT_ClassTypeNames based on the struct S_DisplayName.
As row name set the value to match the DisplayName set in your Enum (UMETA ).
As LocName set the name you want to be translated.
4 - Now in your UMG (or wherever you need to get the translated version of your Enum) from the Enum value → ToString → Get Data Table Row (DT_ClassTypeNames)
5 - Pass the ToString value as argument RowName of the Get Data Table Row Node, this will output a struct containing your LocName, which will translate.

Example:

In this case I use it for the EquipmentType Enum value: