通过 UE的反射机制来查找类里面的所有UPROPERTY,UFUCTION
Property 涵盖了 UE 中所有的原生类型
Property 是以链表的形式存储的,UE 中提供了两种遍历方式:
- TFieldIterator
- FPropertyValueIterator
示例:
UObject*Content;
for (TFieldIterator<FProperty> PropertyIter(Content->GetClass()); PropertyIter; ++PropertyIter)
{
FProperty* PropertyIns = *PropertyIter;
FString ValueString;
AllPropertyNames.Add(MakeShareable(new FString(PropertyIns->GetName())));
const void* PropertyValue = PropertyIns->ContainerPtrToValuePtr<void>(Content);
PropertyIns->ExportTextItem(ValueString, PropertyValue, NULL, NULL, 0);
FText Key = PropertyIns->GetName();
}