How to handle property updates in code?

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,
PostEditChangeProperty

On UProperty manipulation: Access Blueprint vars from c++ q1, Access Blueprint vars from c++ q2

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.

4 Likes