How to use a Bitflags parameter in a BlueprintCallable function
I'm trying to write a BlueprintCallable function that takes in a Bitflags parameter. Inside the function I want to use basic bitwise operations on the parameter. I was able to finally get it working but it seems hacky and like I'm doing something wrong. If anyone has any suggestions it would be greatly appreciated. This is what I have.
Enum (defined as bitflags):
Function with bitflag parameter
The main issue I'm having is that EFlipFlags is of type uint32 but the parameter, flags, is of type int32. This makes it so that I have to do a kinday hacky bitshift flags >>= 1 in order to convert the singed bits to unsigned bit. My question is kind of vague but is there a better way I should be doing this? If I could just change the parameter from a int32 to a uint32 it would seem a lot better to me but the fact that the enum has to be unsigned and the parameter has to be signed makes me thing I'm doing something wrong. Any tips?
you could use
You can also use Bitmask specifier for blueprint, ofcorse this wont change how C++ will deal with it, so you still need to do the above but it should help out on blueprint part:
Not sure if this works with UPARAM for functions arguments, you need to test it
Follow this question
Once you sign in you will be able to subscribe for any updates here