This is actually as-designed behavior - the enum values are currently assumed to be flag indices and not actual flag mask values. That is, the editor will compute (1 << N) where N is the value of the enum. This is consistent with how user-defined enums work on the editor side.
Can see how it would be useful to be able to designate native C++ enums as literal mask values though, especially when used alongside ENUM_CLASS_FLAGS().
Note for testing: After the fix is applied, modify the line above (in MyActor.h) as follows:
UENUM(BlueprintType, meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor="true"))
When a custom enum is used as the Bitmask Enum of a Make Bitmask node, the value returned does not match the expected value
UENUM(BlueprintType, meta = (Bitflags)) enum ETest { BITFLAG1 = 1 UMETA (DisplayName = "BitFlag 1"), BITFLAG2 = 2 UMETA(DisplayName = "BitFlag 2"), BITFLAG3 = 3 UMETA(DisplayName = "BitFlag 3"), BITFLAG4 = 4 UMETA(DisplayName = "BitFlag 3"), };
TestBitmask = 0; TestBitmask |= ETest::BITFLAG1; TestBitmask |= ETest::BITFLAG3;
Result:
First Print String (from code) prints 5 as expected. Second Print String (Make Bitmask node) prints 18.
Expected:
Number 5 gets printed to the screen twice.
Head over to the existing Questions & Answers thread and let us know what's up.
8 |
Component | UE - Gameplay - Blueprint |
---|---|
Affects Versions | 4.12.4 |
Target Fix | 4.16 |
Fix Commit | 3347562 |
---|---|
Main Commit | 3358685 |
Created | Jul 5, 2016 |
---|---|
Resolved | Mar 15, 2017 |
Updated | Sep 13, 2023 |