通過 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();
}
浙公網安備 33010602011771號