Get property value

Hi.

I’m trying to get property value but I don’t know how to do it.

That’s what I have right now:

for (TFieldIterator<UProperty> PropIt(Obj->GetClass()); PropIt; ++PropIt)
{
	UProperty* Property = *PropIt;
	FString type = Property->GetCPPType();
	FString name = Property->GetNameCPP();
	FString value; // How do I get the property value? I expected something like Property->GetPropertyValue_InContainer(Obj).ToString();
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::White, TEXT(""+type+" "+name+" = "+value));
}

Thanks in advance for help.

**

How it was solved.

**

According to what said. To get the property value you need to access a class instance like UBoolProperty, UNumericProperty etc. I solved it by iterating through appropriate fields like below for bool properties.

void UUPropertiesInformer::ShowBoolProperties(UObject* Object, bool PrintToLogs)
{
// My custom printing method
	PrintMessage("SHOWING BOOL PROPERTIES OF " + Object->GetName(), PrintToLogs);
// Iterating through bool properties
	for (TFieldIterator<UBoolProperty> Property(Object->GetClass()); Property; ++Property)
	{
 // "Converting" bool to string
		FString value = Property->GetPropertyValue_InContainer(Object) ? "true" : "false";
		PrintMessage("bool " + Property->GetNameCPP() + " = " + value, PrintToLogs);
	}
}

UProperty is base class for any type of properties, you won’t get much from it other then void pointers (unknown type pointers) to properties. I guess you need to cast to specific property type like UBoolProperty or UNumericProperty depending on what type of property you deal with

Anyone can share how to cast UProperty to specific properties and get values from it?

Simply use Cast, for example:

UBoolProperty* BoolProperty = Cast<UBoolProperty>(MyProperty);