Constraining UPROPERTY to a BP Enum

Hi there,

As the topic suggests, I’d like to be able to create an Enum in the editor and have it referenced in a C++ class. Now I know how to obtain it with UEnum, but, how do I constrain it?

I mean if I instantiate my C++ object from the editor I would like to be able to set the created UPROPERTY only toa value of that specific Enum.

No, as any blueprint information, it exists only virtually as asserts and everything being registed to reflection system on runtime, it that does not exist in C++ during compilation time.

But there is possibility to some hacks, C++ enums are form of integer constants and they being converted back to numbers during compilations, there for enum variables are practicly integer varbales undercover, similar to pointers. So if you can figure how UEnum assigns numbers on those you might able to blueprint enums. Still you will need to do it via UProperty objects as again those are runtime generated varbales, or else you gonan do soem trickery with integer variables.

There for it is always better to declare structures and enums in C++ if you have that possibility, so both C++ and Blueprint are aware of there existence and you can support those at fullest. Structure and Enum asset support in blueprint was practically for blueprint only developers and they didn’t even came day 1 to UE4.

1 Like

Thx yeh that makes sense and I don’t mind going to C++ Enums, but was thinking for the rest of the team it might be “easier” to edit / add values to the Enum in the editor rather than asking me.