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"

Generically list Properties of a UObject

Hi, I am looking for a way to generically list the members (UProperties if needed) of a class. I know I can access them by name with FindPropertyByName, which I think is super usefull. Now I am looking for a way to get the names of the members generically.

I would for example have a TArray with instances of a baseclass in it. I would then iterate over the instances and ask for members of the subclasses. I know that I could achive that with a virutal method (and GetNativePropertyValues is kind of that), I just want to know if there already is something I could use. GetNativePropertyValues kind of fits, but it does more then I want and I'd need to implement that for each subclass, which would be nice to avoid. Although of course not a real problem if I have to. Building on that, I would also like to filter the Properties based on a UProperty modifier.

Greetings, Simon

Product Version: UE 4.13
more ▼

asked Nov 28 '16 at 05:39 PM in C++ Programming

avatar image

1.3k 46 29 59

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

1 answer: sort voted first

You can grab and even filter UProperties of a class using TFieldIterator. UField is most lowest reflection system class, which included UFunction, UProperty, UClass etc so you can use it not just for properties but also functions


You can use it like this:

 for (TFieldIterator<UProperty> It(UClassPointerOfClassYouWantPropertiesToBeListed); It; ++It) {

You don't need to make array you can do somethng with properties stright away

more ▼

answered Nov 28 '16 at 06:00 PM

avatar image

37.2k 936 172 1116

avatar image pulp_user Nov 28 '16 at 06:25 PM

Perfect Answer! Works flawlessly! I did the further filtering like this:

UPROPERTY(EditAnywhere, BlueprintReadWrite, Meta = (ExposeOnSpawn, TEST))

if (it2->HasMetaData("TEST"))

It really is a joy to programm when everything works as expected (except that dereferencing operator doing type conversion catches me offguard every time :D). Thank you so much!!

(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