UENUM Default Value

Say I wanted to create an enum in C++, simple enough:

enum MyTestEnum
{
    MTE_Test_1 = (1 << 0),
    MTE_Test_2 = (1 << 1),


    MTE_LAST = (1 << 31)
};

Now I want to expose this to Blueprints, so I change it a bit by following this tutorial:

UENUM(BlueprintType)
enum class MyTestEnum : uint8
{
    MTE_Test_1 = (1 << 0) UMETA(DisplayName="Test 1"),
    MTE_Test_2 = (1 << 1) UMETA(DisplayName="Test 2"),


    MTE_LAST = (1 << 31) UMETA(Hidden)
};

This doesn’t compile. However removing the values from the enum compiles just fine. How can I assign a value to each entry in the enum?

Hi,

UnrealHeaderTool does not parse general enum value expressions. You should expand those out yourself:

UENUM(BlueprintType)
enum class MyTestEnum : uint8
{
    MTE_Test_1 = 0x00000001 UMETA(DisplayName="Test 1"),
    MTE_Test_2 = 0x00000002 UMETA(DisplayName="Test 2"),

    MTE_LAST = 0x80000000 UMETA(Hidden)
};

Hope this helps,

Steve

An enum of uint8 can not hold (1 << 31), right?

Absolutely right, yes.