通过 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();

}

posted on 2023-05-12 09:51  huaking  阅读(163)  评论(0编辑  收藏  举报

导航