Getting all (public) properties of a UClass

Hey there,

I know it is possible to check if the UClass has a particular UProperty using HasProperty(), but I do not even know how go get such a UProperty. I had imagined the UClass would contain methods to check for properties by their names, or to get all properties, but it would seem I’d be wrong there.

I’ve done several Google searches and am still searching to find any tutorial or other relevant information in the documentation, but my search so far has been in vain. Thus I thought I’d ask here to maybe speed up things.

Thank you for any information!

Zyr

1 Like

I found what I was looking for. It is possible to iterate over the fields of a class using the TFieldIterator type and the FindField() global function.

Example for TFieldIterator:

for( TFieldIterator<UBoolProperty> Prop(MyUClassPtr); Prop; ++Prop ) {
    bool val = Prop->GetPropertyValue(MyUObjectPtr);
}

where MyUClassPtr is a pointer to an instance of UClass and MyUObjectPtr is a pointer to an instance of UObject.

1 Like

If you want to iterate over every UPROPERTY regardless of its type then you can use TFieldIterator<UProperty> instead, just fyi.

1 Like

It’s FProperty these days btw.

3 Likes