C++ Bitflags - Can only select one at a time in details panel

I’ve got an enum marked with ENUM_CLASS_FLAGS.

UENUM(BlueprintType, meta = (Bitflags))
enum class EMovementTrackingFlags : uint8
{
	None = 0,

	X,
	Y,
	Z,
};
ENUM_CLASS_FLAGS(EMovementTrackingFlags);

Then, elsewhere in another class, I’ve declared a variable of this kind.

UPROPERTY(EditAnywhere, Category = "Tracking Settings", meta=(Bitmask, BitmaskEnum = "EMovementTrackingMode"))
	EMovementTrackingFlags movementTrackingFlags;

Everything seems to work okay so far as this compiles properly, but when I go into the editor to check it out…

107205-movementtrackingflagswrong.png

I’m only able to select one of these at a time, IE it is behaving like a standard enum instead of like flags. Does anybody have any insight as to what’s wrong with this bitflag definition?

Changing the enum declaration to an integer with the same properties results in the details panel displaying this as flag values.

107206-intflag.png

Multiple values can be selected, however they are mis-labeled.

Solved.

I made two mistakes. First, the variable declaration must be an integer of a type appropriate to the defined Enum it is intended to represent. Second, I mis-typed the name, which was inconsistent with the enum’s actual name. It was “EMovementTrackingFlags,” not “EMovementTrackingMode”.

	UPROPERTY(EditAnywhere, Category = "Tracking Settings", meta=(Bitmask, BitmaskEnum = "EMovementTrackingFlags"))
	uint8 movementTrackingFlags;

Fixing both of these issues causes the enum to appear correctly as flag values. It is necessary to revise the list of flag values, in that the one provided above lists “None” as a separate value rather than the exclusion of all values. I am yet to determine why this is, but will explore that as a separate issue.

1 Like