# How to handle property updates in code?

**URL:** <https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731>\
**Category:** Blueprint\
**Tags:** properties, update, unreal-engine, question, Blueprint, CPP\
**Created:** [July 9, 2014, 9:21am UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731 "2014-07-09T09:21:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_7a9aff171](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7a9aff171](https://forums.unrealengine.com/u/anonymous_user_7a9aff171)\
**Post date:** [July 9, 2014, 9:21am UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/1 "2014-07-09T09:21:08Z")

</div>

I have a custom Actor class, and a couple of derived blueprints with specific defaults.  
I am initializing Components with these new defaults inside overridden OnConstruction, and it works. However, I would also like to change blueprint properties in real time and see the effect immediately, how can I achieve this?.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_de292077](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_de292077](https://forums.unrealengine.com/u/anonymous_user_de292077)\
**Post date:** [July 9, 2014, 9:38pm UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/2 "2014-07-09T21:38:40Z")

</div>

I would like to know as well. Is there a callback in the component for when a property has been changed in the editor? Thanks!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_7a9aff171](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_7a9aff171](https://forums.unrealengine.com/u/anonymous_user_7a9aff171)\
**Post date:** [July 10, 2014, 1:03pm UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/3 "2014-07-10T13:03:50Z")

</div>

After some forum searching, I have found some functions which handle object property updates: PostEditChangeProperty for regular UProperties and PostEditChangeChainProperty for TArrays.  
They are invoked as follows:

```
//for regular properties:
void ACustomClass::PostEditChangeProperty(struct FPropertyChangedEvent& e)
{
	FName PropertyName = (e.Property != NULL) ? e.Property->GetFName() : NAME_None;
	if (PropertyName == GET_MEMBER_NAME_CHECKED(UCustomClass, PropertyName))
	{
        //various uproperty tricks, see link
	}
    Super::PostEditChangeProperty(e);
}

//for TArrays:
void ACustomClass::PostEditChangeChainProperty(struct FPropertyChangedChainEvent& e)
{
    int32 index = e.GetArrayIndex(TEXT("Meshes")); //checks skipped
    UStaticMesh *mesh = Meshes[index]; //changed mesh
    Super::PostEditChangeChainProperty(e);
}

```

Retrieved from these links:  
[PostEditChangeChainProperty](https://answers.unrealengine.com/questions/48352/how-can-i-get-the-tarray-index-on-posteditchangepr.html),  
[PostEditChangeProperty](https://forums.unrealengine.com/showthread.php?6599-OnPropertyChanged-or-similiar-does-it-exist)

On UProperty manipulation: [Access Blueprint vars from c++ q1](https://answers.unrealengine.com/questions/2145/how-to-access-blueprint-vars-in-c.html), [Access Blueprint vars from c++ q2](https://answers.unrealengine.com/questions/4454/how-to-access-a-bp-script-array-fscriptarray-and-m.html)

Unfortunately, I have yet to figure out how to trace component property changes. There is, however, a rather obscure delegate (FCoreDelegates::OnObjectPropertyChanged), which might be configured to call your function on component property updates. For me, it does not work. Maybe it would be easier just to use a custom component class with overridden PostEditChangeProperty.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_6dbe8be9](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_6dbe8be9](https://forums.unrealengine.com/u/anonymous_user_6dbe8be9)\
**Post date:** [October 10, 2015, 5:23am UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/4 "2015-10-10T05:23:49Z")

</div>

This is awesome, thank you so much.

---

<div class="post-metadata">

**Author:** ![UnexpectedSquirt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnexpectedSquirt](https://forums.unrealengine.com/u/UnexpectedSquirt)\
**Post date:** [October 2, 2016, 2:53pm UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/5 "2016-10-02T14:53:17Z")

</div>

Dude, thanks! this is super useful information!

---

<div class="post-metadata">

**Author:** ![WHSolv](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WHSolv](https://forums.unrealengine.com/u/WHSolv)\
**Post date:** [June 23, 2017, 5:32am UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/6 "2017-06-23T05:32:31Z")

</div>

Doesn’t it work only inside of Editor?..

---

<div class="post-metadata">

**Author:** ![Vertex\_Soup](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Vertex\_Soup](https://forums.unrealengine.com/u/Vertex_Soup)\
**Post date:** [July 11, 2017, 5:24pm UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/7 "2017-07-11T17:24:15Z")

</div>

Yes it does only work in editor and need to have #if WITH\_EDITOR in both H and CPP files

---

<div class="post-metadata">

**Author:** ![darkgaze](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@darkgaze](https://forums.unrealengine.com/u/darkgaze)\
**Post date:** [January 22, 2018, 3:47pm UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/8 "2018-01-22T15:47:07Z")

</div>

I will add that it must be #if and not #ifdef because WITH\_EDITOR is always declared.  
Also #endif should be put at the end, in case somebody doesn’t know.  
Here’s an example, probably one of the very few you will find nowadays in the docs: [AActor::PostEditChangeProperty | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/GameFramework/AActor/PostEditChangeProperty/)

---

<div class="post-metadata">

**Author:** ![darkgaze](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@darkgaze](https://forums.unrealengine.com/u/darkgaze)\
**Post date:** [March 1, 2018, 7:28pm UTC](https://forums.unrealengine.com/t/how-to-handle-property-updates-in-code/287731/9 "2018-03-01T19:28:22Z")

</div>

Declare them in the header like this:  
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
