I’m working on level scripting tool that uses the reflection system heavily. I have the pointer to a UFunction
and I want to list out the function parameters and their types (bool, float, object*, etc..).
Is it possible to get the type name for an FProperty
or do I need to compare against the different property classes and make up a string myself?
This is what I have so far:
UFunction* Function = TargetObject->FindFunction(...); // function ptr
for (TFieldIterator<FProperty> It(Function); It && It->HasAnyPropertyFlags(CPF_Parm); ++It)
{
FProperty* LocalProp = *It; // function param ptr
checkSlow(LocalProp);
FString PropName = LocalProp->GetFName().ToString(); // param name
FFieldClass* PropClass = LocalProp->GetClass();
FString PropType = PropClass->GetFName().ToString(); // param type
if (PropClass->IsChildOf(FStructProperty::StaticClass()))
{
FStructProperty* StructProp = CastField<FStructProperty>(LocalProp);
UStruct* Struct = StructProp->Struct;
PropType = Struct->GetFName().ToString(); // if param is a struct, use struct name instead
}
UE_LOG(LogTemp, Log, TEXT("(%s) %s"), *PropType, *PropName);
}