UE5 Converting Enums to FString In C++

Table of Contents

Sometimes you may need to convert an enum to a string without using switch or if else blocks. Here’s a generic way of converting any UEnum to FString:

				
					UENUM(BlueprintType)
enum class MyEnum : uint8
{
	None			 UMETA(DisplayName = "(none)"),
	Quarter			 UMETA(DisplayName = "1/4")
}

auto MyEnumValue=MyEnum::Quarter;

//This will get the "DisplayName" of the Enum. Eg "1/4)
UEnum::GetDisplayValueAsText(MyEnumValue).ToString();

//This gets the Name of the enum, eg "Quarter"
UEnum::GetValueAsString(MyEnumValue); 


				
			
5/5

Gamechanger plugin for notehighway rhythm games and music visualizers

5/5

Add Text and 2D UMG widgets to Level Sequences

5/5

Simplify your Plugin Development with the Unreal Projects Manager

5/5

Learn how to create unreal engine plugins from scratch and sell them on Fab.com.