# Set  values using Property System (Reflection)

**URL:** <https://forums.unrealengine.com/t/set-values-using-property-system-reflection/489537>\
**Category:** Rendering\
**Tags:** UProperty, reflection, unreal-engine, CPP, question\
**Created:** [October 5, 2021, 8:13am UTC](https://forums.unrealengine.com/t/set-values-using-property-system-reflection/489537 "2021-10-05T08:13:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bionic\_Ape](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bionic_ape/32/1090124_2.png) [@Bionic\_Ape](https://forums.unrealengine.com/u/Bionic_Ape)\
**Post date:** [October 5, 2021, 8:13am UTC](https://forums.unrealengine.com/t/set-values-using-property-system-reflection/489537/1 "2021-10-05T08:13:56Z")

</div>

Hi,

It’s about the same problem of [another question that I asked](https://answers.unrealengine.com/questions/1052207/view.html) but I’m going to try to frame it differently:

I have strings with values that can be floats, int32s, object references, FStrings or FNames. I know how to cast the FProperty so I get the correct type, but then I don’t know how to set it to the object that has that FProperties.

I’ve seen some examples in the engine, but ultimately they use a uint8\* that I assume it is the actual address of the property of the object in memory. Am I right? How can I get that? Is `SetPropertyValue` and `SetPropertyValue_InContainer` the way to go?

How can I get an UObject, get all the FProperties, cast those FProperties to FStrProperty, FObjectProperty, FFloatProperty and so on, and then set the value to the instance of that UObject?

Thanks!

---

<div class="post-metadata">

**Author:** ![Bionic\_Ape](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/bionic_ape/32/1090124_2.png) [@Bionic\_Ape](https://forums.unrealengine.com/u/Bionic_Ape)\
**Post date:** [October 5, 2021, 5:31pm UTC](https://forums.unrealengine.com/t/set-values-using-property-system-reflection/489537/2 "2021-10-05T17:31:44Z")

</div>

Well, I found out a way, I think that’s the best way, but if someone finds a better way, please let me know.

```
//FObjectProperty
if (const FObjectProperty* ObjectProperty = CastField<const FObjectProperty>(PropertyHelper.Property))
{
	//get reference
	if (UObject* Object = LoadObject<UObject>(nullptr, *CellValue))
	{
		if (UObject** ValuePtr = ObjectProperty->ContainerPtrToValuePtr<UObject*>(Item))
		{
			*ValuePtr = Object;
		}
	}
}
//FIntProperty
else if (const FIntProperty* IntProperty = CastField<const FIntProperty>(PropertyHelper.Property))
{
	if (int32* ValuePtr = IntProperty->ContainerPtrToValuePtr<int32>(Item))
	{
		*ValuePtr = UKismetStringLibrary::Conv_StringToInt(CellValue);
	}
}
//FFloatProperty
else if (const FFloatProperty* FloatProperty = CastField<const FFloatProperty>(PropertyHelper.Property))
{
	if (float* ValuePtr = FloatProperty->ContainerPtrToValuePtr<float>(Item))
	{
		*ValuePtr = UKismetStringLibrary::Conv_StringToFloat(CellValue);
	}
}
//FStrProperty
else if (const FStrProperty* StrProperty = CastField<const FStrProperty>(PropertyHelper.Property))
{
	if (FString* ValuePtr = StrProperty->ContainerPtrToValuePtr<FString>(Item))
	{
		*ValuePtr = CellValue;
	}
}
//NO MATCHING PROPERTY
else
{
	UE_LOG(LogInventoryItemFactory, Log, TEXT("No Matching Property with the compatible values: '%s'"), *KeyName);
}
```

---

<div class="post-metadata">

**Author:** ![ImmaFake2000](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ImmaFake2000](https://forums.unrealengine.com/u/ImmaFake2000)\
**Post date:** [August 15, 2024, 8:21am UTC](https://forums.unrealengine.com/t/set-values-using-property-system-reflection/489537/3 "2024-08-15T08:21:01Z")

</div>

> [@Bionic\_Ape](#):
>
> How can I get an UObject, get all the FProperties, cast those FProperties to FStrProperty, FObjectProperty, FFloatProperty and so on, and then set the value to the instance of that UObject?

This is exactly what i want to do. But following your step, the property changing can only be seen in the details table. which means that I can not see the changing in the view port. I think may be the way to get the object and property is wrong? I did not get the instance in the level?

could you please provide me with a relative full code which also shows how to get the “item” and “property”? Much thanks
