Download

Set Property with TFieldIterator <UProperty> does not change value, why?

I’m trying to change the properties of any object through the TFieldIterator <UNameProperty> …

Running my code with Begin Play I can actually print on the screen the value of some property, then change it and print property value modified … .
nothing else happens to the object after the value has been changed …

I’m trying to change the intensity of a lamp … the code seems to work and when I get the properties of the lamp returns the value that has been modified over the lamp not changes in intensity … why?



void UIllusionToolkit::SetFloats(UObject* Object, FName PropertyName, float PropertyValue)
{
	UProperty* Property = Object->GetClass()->FindPropertyByName(PropertyName);

	if (UNumericProperty *NumericProperty = Cast<UNumericProperty>(Property))
	{
		if (UFloatProperty *FloatProperty = Cast<UFloatProperty>(NumericProperty))
		{
			void* ValuePtr = FloatProperty->ContainerPtrToValuePtr<void>(Object);
			FloatProperty->SetFloatingPointPropertyValue(ValuePtr, PropertyValue);
		}

	}
}


That’s probably because you need to notify the lamp, that the property is changed. Look at PostEditChangeProperty method