Download

How to get/set array property by name

I am using this code to get/set and int property by name.

bool UMyBPFunctions::SetIntByName(UObject* Target, FName VarName, int in)
{
    if (Target)
    {
        FProperty* property = Target->GetClass()->FindPropertyByName(VarName);
        if (!property)
        {
            return false;
        }
        FIntProperty* typedProperty = CastField<FIntProperty>(property);
        if (!typedProperty)
        {
            return false;
        }

        void* propertyAddress = property->ContainerPtrToValuePtr<void>(Target);

        typedProperty->SetPropertyValue(propertyAddress, in);
        return true;
    }
    return false;
}

Does anyone know how I can do this for a TArray if integers?

Found the answer here:
https://answers.unrealengine.com/questions/830265/modifying-the-value-of-an-fstring-in-an-array-with.html