Algosyntax Logo

UE5 Converting Enums to FString In C++

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); 


				
			

MIDI Engine 3 For UE5

5/5

Gamechanger plugin for notehighway rhythm games and music visualizers

5/5

Add Text and 2D UMG widgets to Level Sequences

Consider investing in some of our plugins. They might save you some time.  Also helps supports these tutorials.

Instantly get access to our plugins like Blender Curves Importer and UMG Cinematics and more when  you support us on Patreon!

 Join Us On Discord For More Daily Tips!