AnimationMode.AddPropertyModification restores incorrect value after value is set back and forth.

Hi there,
With AnimationMode api, what is the proper way to use AddPropertyModification when the property is modified several times in a row from scripts ?

After adding the binding,
If the property is modified only once in the code, then it is restored correctly on exiting preview and prefab value is not considered overriden
Key A:


Restored :

if the property is modified with a different value then it is restored to the wrong value and prefab is considered overriden :
Key A


Key B

Restored
9892005--1427952--upload_2024-6-15_19-27-12.png

if it is set back to the first modified key value, then it is restored correctly
Key A


Key B

Key C

Restored :

I tried both adding or not adding a new PropertyModification on the second modification by checking
var isPropertyAnimated = AnimationMode.IsPropertyAnimated(target, kinematic.propertyPath); but the result is the same.

I’m quite new to this API so I might be doing something wrong.

Below the way we add the Property binding

var kinematicBinding = EditorCurveBinding.DiscreteCurve(inPath+nameof(Rigidbody) , typeof(Rigidbody), kinematic.name);
            var propModification = new PropertyModification
            {
                target = target,
                propertyPath = kinematic.propertyPath,
                value = target.isKinematic.ToString()
            };
            AnimationMode.AddPropertyModification(kinematicBinding, propModification, true);

Answering my own issue :
Apparently you have to cache the PropertyModification and just update the .value whenever you do modifiy the property value in your script. It kinda makes sense regarding what the doc says "
Defines a single modified property. Used by the Prefab system to track any changes applied to an instance."

            var isPropertyAnimated = AnimationMode.IsPropertyAnimated(target, kinematic.propertyPath);
            var kinematicValue = target.isKinematic.ToString();
            if (isPropertyAnimated && _propModification != null)
            {

                _propModification.value = kinematicValue;
                return;
            }
            var kinematicBinding = EditorCurveBinding.DiscreteCurve(inPath+nameof(Rigidbody) , typeof(Rigidbody), kinematic.name);
          
            _propModification = new PropertyModification
            {
                target = target,
                propertyPath = kinematic.propertyPath,
                value = kinematicValue
            };
          
            AnimationMode.AddPropertyModification(kinematicBinding, _propModification, true);