Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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.

Product Version: UE 4.20
more ▼

asked Nov 01 '18 at 03:45 PM in C++ Programming

avatar image

10 4 7 8

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Nov 01 '18 at 04:02 PM

avatar image

37.2k 936 172 1116

avatar image djmulder Nov 01 '18 at 04:06 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question