C++ function with UENUM input shows it as "unsupported" in BP

Hello!

So, I’ve created a very simple UENUM in my custom Actor’s .h header file, which looks like this:

image

Please have in mind that this UENUM declaration is outside my custom Actor’s UCLASS declaration, but in the same .h header file (just above the UCLASS declaration).

Then, inside the UCLASS, I have a UFUNCTION being declared, and also defined in the .cpp file, as follows:

As you can see, the function takes one such UENUM as input. All works fine inside C++, I can use it in all sorts of code, however when trying to expose it to BP, the following happens:

What you’ll notice is that BP has no problem identifying my UENUM, as it can correctly create a Literal of it, with all of the fields displayed correctly. However, the problem is with my Function that takes such an UENUM as input, since for some reason, it fails to properly detect the input, giving out the following error (you can also see it in the above screenshot):

unsupported_enum_type: enum size is larger than a byte

Any idea as to what I might be doing wrong?
Thank you so much!

You haven’t specified the type to use for the enum. The definition should look like this:

enum class EDifficultyLevels : uint8

1 Like

Thank you so much!!! :heart_eyes: You’re absolutely right indeed, I never knew that was actually a thing in UE to be honest…

Plus, after further discussions on Discord, it now became apparent to me that UENUMS must “inherit” from the primitive type uint8, so that their size is exactly 1 Byte, in order for them to be able to be properly exposed to Blueprint.

Btw, UENUMs only support up to 32 values (ranged 0 -31), so not even the full 256 spectrum (0 - 255) of 1 Byte!!! Since regular C++ has no such restrictions, this was totally unbeknownst to me, but now it all makes sense. So, for UENUMS always do a:

enum class EMyEnum : uint8

if you wish to expose your UENUM to BP! Otherwise, for regular C++ cases and regular enums, it’s not mandatory. :muscle:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.