EnumToString Macro - Epic Wiki
# EnumToString Macro
# Contents
# Overview
Macro that lets you quickly get an enum value as a FString for use in logging etc.
Caveat - only works with enumerators defined using UENUM() macro.
# YourProject.h
#define GETENUMSTRING(etype, evalue) ( (FindObject
# Usage
# YourClass.h
UENUM() enum class EUsesEnum : uint8 { UseEnum_Bad, UseEnum_Good, UseEnum_Nice, UseEnum_Naughty };
# YourClass.cpp
void AYourClass::SomeFunction() { EUsesEnum UseEnumValue = EUsesEnum::UseEnum_Good; UE_LOG(LogSomething, Log, TEXT("UseEnumValue as string : %s"), *GETENUMSTRING("EUsesEnum", UseEnumValue)); }
Output:
LogYourCategory: UseEnumValue as string : UseEnum_Good
# Credits
Retrieved from "https://wiki.unrealengine.com/index.php?title=EnumToString_Macro&oldid=14099"