# Setting the value of an Instance of UProperty

**URL:** <https://forums.unrealengine.com/t/setting-the-value-of-an-instance-of-uproperty/442054>\
**Category:** UI\
**Tags:** UProperty, property-customizati, unreal-engine, Widget, UE4, CPP, question\
**Created:** [January 25, 2019, 12:48pm UTC](https://forums.unrealengine.com/t/setting-the-value-of-an-instance-of-uproperty/442054 "2019-01-25T12:48:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DexDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DexDev](https://forums.unrealengine.com/u/DexDev)\
**Post date:** [January 25, 2019, 12:48pm UTC](https://forums.unrealengine.com/t/setting-the-value-of-an-instance-of-uproperty/442054/1 "2019-01-25T12:48:43Z")

</div>

Hi all!

I’m trying to set the value of a UProperty on a UMG Spinbox, then when the SpinBox value changes, set that value back on the Property. For that, I’m doing the next:

I iterate through all properties of an object with a specific Meta, then build another Widget (the widget that has the SpinBox) depending on the type that contains its Meta and finally pass the UProperty to the created new Item:

```
// Get properties of the owner and its components
  TArray<UProperty*> PropertiesToShow;
  static FMargin Padding(100);
  for (TFieldIterator<UProperty> It(OwnerActor->GetClass()); It; ++It)
  {
    if (It->HasMetaData("ModifiableProperty"))
    {
      UPropertyEditorItem* Item = nullptr;
      switch (It->GetINTMetaData("ModifiableProperty"))
      {
        case 0:
          Item = NewObject<UPropertyEditorItem>(this, PropertyWidgetClassFloat);
        break;
        case 1:
          Item = NewObject<UPropertyEditorItem>(this, PropertyWidgetClassInt);
        break;
        case 2:
          Item = NewObject<UPropertyEditorItem>(this, PropertyWidgetClassBool);
        break;
      }
      // Fill Item and add to Hierarchy
      if (Item)
      {
        ScrollBox->AddChild(Item);
        Item->SetupItem(OwnerActor, *It);
        Item->SetPadding(Padding);
      }
    }
  }

```

Until here everything is working fine as expected, getting the values of the UProperty works well, but then when I try to modify the value of any of the above properties, It doesn’t change. I’ve read in many other answers that UProperty contains the value and information of the Property but it isn’t the instance of it, so when changing it, nothing happens.

This is how I’m doing it:

```
void UPropertyEditorItemFloat::SetupItem(APickupableActor* PickupObj, UProperty* Property)
{
  Super::SetupItem(PickupObj, Property);
  ValuePtr = Cast<UFloatProperty>(Property);
  if (ValuePtr)
  {
    PropertySpinBox->SetValue(*ValuePtr->ContainerPtrToValuePtr<float>(PickupObj));
    ValueChanged.BindUFunction(this, "UpdateValue");
    PropertySpinBox->OnValueChanged.Add(ValueChanged);
  }
}

void UPropertyEditorItemFloat::UpdateValue()
{
  ValuePtr->SetPropertyValue(PickupProperty, PropertySpinBox->GetValue());
}

void UPropertyEditorItemFloat::SyncValue()
{
  PropertySpinBox->SetValue(*ValuePtr->ContainerPtrToValuePtr<float>(PickupProperty));
}

```

I’m really upset because I’ve been like a week researching in the API and Forums, trying so many things but nothing worked out.

I hope you can help me, thanks in advance!

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [January 26, 2019, 3:10am UTC](https://forums.unrealengine.com/t/setting-the-value-of-an-instance-of-uproperty/442054/2 "2019-01-26T03:10:10Z")

</div>

Maybe try this function instead:

> **[TProperty\_Numeric::SetFloatingPointPropertyValue](https://docs.unrealengine.com/5.1/en-US/API/Runtime/CoreUObject/UObject/TProperty_Numeric/SetFloatingPointPropertyValue/)**
>
> Set the value of a floating point property type

You can find API reference here, check parent classes too:

[https://api.unrealengine.com/INT/API/Runtime/CoreUObject/UObject/UFloatProperty/index.html](https://api.unrealengine.com/INT/API/Runtime/CoreUObject/UObject/UFloatProperty/index.html)

Also do set function is actually called? make sure by placing breakpoint on it

---

<div class="post-metadata">

**Author:** ![DexDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DexDev](https://forums.unrealengine.com/u/DexDev)\
**Post date:** [January 26, 2019, 10:07am UTC](https://forums.unrealengine.com/t/setting-the-value-of-an-instance-of-uproperty/442054/3 "2019-01-26T10:07:18Z")

</div>

Thanks, Shadow!

Works like a charm!

I’m leaving the call of the function below if anyone is wondering how to do it:

```
void UPropertyEditorItemFloat::UpdateValue()
{
  ValuePtr->SetFloatingPointPropertyValue(PickupProperty->ContainerPtrToValuePtr<float>(PickupPropertyOwner), PropertySpinBox->GetValue());
}
```
