UEnum in Unreal Engine 5 C++
Syntax
UENUM(BlueprintType)
enum class ECustomEnum : uint8 {
ValueA UMETA(DisplayName="My Value 1"),
ValueB,
ValueC
};
Bitflag Syntax
UENUM(BlueprintType, meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor = "true"))
enum class ECustomBitFlagEnum: uint8
{
BitValueNone = 0,
BitValueA = 1 << 0,
BitValueB = 1 << 1,
BitValueC = 1 << 2
};
ENUM_CLASS_FLAGS(ECustomBitFlagEnum);
ECustomBitFlagEnum MyBitFlag = ECustomBitFlagEnum::FlagA | ECustomBitFlagEnum::FlagC;
MyBitFlag |= ECustomBitFlagEnum::FlagB;
MyBitFlag &= ~ECustomBitFlagEnum::FlagA;
bool bIsFlagActive = (MyBitFlag & ECustomBitFlagEnum::FlagC) == ECustomBitFlagEnum::FlagC;