Constraining UPROPERTY to a BP Enum
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.
answered Nov 01 '18 at 04:02 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here