I am using a bit of code listed below to reflect on properties of a UStruct. The below works for the types I am interested in such as FString, int32, float, bool… However, when I add a FText field to my structure I am unsure on how to reflect on it, then get the localized or unlocalized value out of it. As FText does not cast to a UStrProperty.
for (TFieldIterator<UProperty> PropIt(Items.GetData()->StaticStruct()); PropIt; ++PropIt)
{
UProperty* prop = *PropIt;
if (dynamic_cast<UStrProperty*>(prop) != nullptr)
{
auto strProp = dynamic_cast<UStrProperty*>(prop);
FString strVal = strProp->GetPropertyValue(&item);
}
else if (dynamic_cast<UNumericProperty*>(prop) != nullptr)
{
auto numProp = dynamic_cast<UNumericProperty*>(prop);
if (numProp->IsInteger())
{
int32 intVal = numProp->GetSignedIntPropertyValue(&item);
}
else if (numProp->IsFloatingPoint())
{
float floatVal = numProp->GetFloatingPointPropertyValue(&item);
}
}
else if (dynamic_cast<UBoolProperty*>(prop) != nullptr)
{
auto boolProp = dynamic_cast<UBoolProperty*>(prop);
bool boolVal = boolProp->GetPropertyValue(&item);
}
}
Best regards,
Justin Walsh