Get text from enum

For example i have an Enum of ItemCategory which consist : weapons, armor, potion

now i print a itemCat variable which is a Itemcategory enum using enum to name function, it shows Itemtype::Enumerator0

what i wan is printing out weapons instead of Itemtype::Enumerator0

currently im using a switch to manually type the name which is hard coded, i want it to automatically print the name of the enum everytime i add a new category

Pretty sure you will have to hard code this unless you want to get into source.

You can drag from the input ItemType and select Enum to String, then convert that String to name

I think it doesn’t work if you use Enum to Name directly, or if you use Byte To String before String To Name.

1 Like

It works! Caution! “Enum to String” returns Enum’s text, “to String” returns Enum-index string.

2 Likes

Note that Enum to String returns the DisplayName in Editor mode and returns its enum’s literal text in Packages game. So it’s not very reliable. I think there’s no way directly converting enum to string in BP. You should write it case by case in CPP. A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums provides how but be aware that templatized version can’t be UFUNCTION