It was to get UFloatProperty or UBoolProperty by name when using TFieldIterator.
But I’m puzzled how to get value of FColor or FLinearColor?
It was to get UFloatProperty or UBoolProperty by name when using TFieldIterator.
But I’m puzzled how to get value of FColor or FLinearColor?
Since FColor is a struct, you can use UStructProperty for that.
Ok, just changed approached and using FindField
for (TPair<FName, uint32> Pair : Dictionary)
{
UStructProperty* Property = FindField<UStructProperty>(Component->GetClass(), Pair.Key);
const FColor* ColorPtr = Property->ContainerPtrToValuePtr<FColor>(Component);
if (ColorPtr)
{
uint32 Value = ColorPtr->DWColor();
}
}
Also I could find Struct with FieldIterator, but I still don’t know how to properly cast UStructProperty to FColor. This code just converts any found struct
for (TFieldIterator<UStructProperty> PropIt(Component->GetClass()); PropIt; ++PropIt)
{
UStructProperty* Property = *PropIt;
FName Name = Property->GetFName();
const FColor* ColorPtr = Property->ContainerPtrToValuePtr<FColor>(Component);
if (ColorPtr)
{
uint32 Value = ColorPtr->DWColor();
}