Bitmask Enum declaration in 4.12, what's missing?
I'm trying to use the Bitmask Enum support in Blueprints, as introduced in UE 4.12 This article explains its usage in Blueprints, but only touches on declaring them in C++. I can't get a C++ declared (bitmask) enum to show up in my Blueprint as a Bitmask Enum type (for integers or for using in the Make Bitmask node). My UENUM daclaration:
The article mentions a
My aim is to eventually create an event with the current state flags as payload, but EState is not recognised as a bitmask.
asked Jun 22 '16 at 10:48 AM in C++ Programming
Made some progress with this, so I'll jot down what I found.
To declare a bitmask enum in C++:
The above enum will now show up in Blueprints as an available Bitmask enum. E.g. define an integer variable in your blueprint, set it to a bitmask and the Bitmask Enum dropdown will allow you to select the above enum. Flags on the bitmask will be shown as named. It also correctly populates Set and Make Bitmask nodes.
Further, to add a bitmask using the specified enum in C++ for use in blueprints, I use
This can be used in blueprints or in C++ with the macro defined methods, e.g.
So far so good. It compiles, all blueprint nodes using the enum have the correct flags and I expect we should be good to go.
New problem: The Make Bitmask blueprint node, with ETest set as its enum returns the wrong values. If I do in code
The integer (decimal) value of the above should be 5. Indeed, if I print that out in a blueprint using 'Print String' then I see 5, as expected. But If I now create a Make Bitmask node to replicate the C++ one, set it's enum to ETest and set the first and third bits, and I print the return value, I get 18.
Bug? Or is there still an issue in the declaration?
answered Jul 01 '16 at 06:16 PM
UEnum Bitflags end up getting re-mapped by index in BP, so if you manually specify the enum bit in C++, it won't be the same once marked as an enum bitflag.
This is how I am using them in C++:
answered Jul 06 '16 at 03:35 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here