Download

How to Get Value UStruct

I make Blueprint Struct and want to use in C++.
how to get value from UProperty?

my code




// "/Game/UI/WidgetPool" is created blueprint struct
UStruct* structPtr = LoadObject<UStruct>(NULL, TEXT("/Game/UI/WidgetPool"), NULL, LOAD_None, NULL);
if (nullptr != structPtr)
{
for (TFieldIterator<UProperty> iter(structPtr); iter; ++iter)
{

UStructProperty* property = Cast<UStructProperty>(*iter);
if (nullptr == property)
continue;

const FString propertyName = property->GetDisplayNameText().ToString();
print_screen(propertyName);

UIntProperty* sizeProperty = FindField<UIntProperty>(testPtr, "poolSize_");
if (sizeProperty)
{

**int value = // how to get value ??**
const FString text1 = FString::Printf(TEXT("%s : %d"), *sizeProperty->GetName(), value);
print_screen(text1);
}
}
}



You would make life easier for yourself if you defined the USTRUCT in C++, then it’s very easy to work with in both C++ and BP.