Enum helpers mostly exist on the UEnum class for the enum.
String representations
StaticEnum<EMyEnum>()->GetDisplayNameTextByValue(static_cast<int64>(SomeEnumValue)));
Get UEnum for an enum type
UEnum* Thing = StaticEnum<ESomeEnumType>();
Get random enum value
template <class T>
static T RandomEnum()
{
UEnum* Enum = StaticEnum<T>();
int32 Num = FMath::RandRange(0, static_cast<int32>(Enum->GetMaxEnumValue()) - 1);
return static_cast<T>(Num);
}
//use:
EMyEnum Val = RandomEnum<EMyEnum>();
Get all enum values
template <class T>
static TArray<T> GetEnumValues()
{
const UEnum* Enum = StaticEnum<T>();
int32 Max = Enum->GetMaxEnumValue();
TArray<T> EnumArray;
EnumArray.Reserve(Max);
for(int32 i = 0; i < Max; i++)
{
EnumArray.Emplace(static_cast<T>(i));
}
return EnumArray;
}
//use:
TArray<EMyEnum> Values = GetEnumValues<EMyEnum>();