Unreal Reflection

Hi guys, I am trying to wrap my head around unreals reflection system, and the few documentation that is available seems quite ok, but nevertheless I cant get it to work since my iterator is constantly nullptr… Here is an example code:

struct FPossibleUnit

int32 m_Key;


FPossibleUnit* myUnit = new FPossibleUnit();
myUnit->m_AttributeKey = 12;
for (TFieldIterator PropIt(FPossibleUnit::StaticStruct(), EFieldIterationFlags::IncludeAll); PropIt; ++PropIt)
UProperty* Property = *PropIt;
FString name = Property->GetName();

what the hell am I missing here. Would be great if anybody could enlighten me :slight_smile:

don’t have exact answer.
but as far as I know, USTRUCT are created in-place without “new” keyword (handled by GC), also you can’t use a pointer to USTRUCT (only reference, or function returns a pointer to an USTRUCT reference).

hi, thx for your reply, I am kind of aware that you should avoid ‘new’ keyword because of unreals gc at least for unreals own classes, but i thought for this example memory leaks are not in consideration :sweat_smile: since it compiles fine and even the init of the member works, i thought the error is elsewhere, i personaly think it has something to do with the iterator and the wrong type in the constructor, but I cant figure out whats wrong, drives me crazy​:sweat_smile:

For anybody out there who is interested in reflection I found the solution to my problem… 'TFieldIterator < FProperty > ’ is valid for FStructs, not UProperty as template type… it seems that has changed over time bc I never found any hint in the documentation about it and every codesnippet i found via google used UProperty…