Set string for FString via UProperty Object

Hi,

i know how to set float or int or event bool by name with the UProperty class (casting to derived UProperty classes like “UNumericProperty” and using appropriate methods like “SetNumericPropertyValueFromString”) but i stuck on setting the value of a FString property via the UProperty Object.

In FMyStructure header there is some declaration like this:

UPROPERTY(EditAnywhere, BlueprintReadWrite,)
FString	Password;

I another place i need to set the value of the variable “Password” dynamically by name:

Step 1. UProperty* Prop = FMyStructure::StaticStruct()->FindPropertyByName(“Password”);
Step 2. No idea how to go on. There is no derived UProperty class which fits FString. It is not possible to cast to UObjectPropertyBase or UStructProperty either which makes sense because FString is not derived from UObject or UStruct. So please tell me how to set the value of a FString property.

Found the solution of myself. Just use ContainerPtrToValuePtr of the basis UProperty object.

FString* ValuePtr = Property->ContainerPtrToValuePtr<FString>(&tempStructure);
if (ValuePtr)
{
       *ValuePtr = FString("this is a string");
}

This should work aswell for other custom classes as member variables marked as UPROPERTY.