Reverting PropertyModification

hi,

I would like to traverse all PropertyModifications (retrieved via PrefabUtility.GetPropertyModifications(instance)), compare instance value with prefab value, and eventually revert the modification via PrefabUtility.RevertPropertyOverride. For reverting I need the SerializedProperty of the instance object, but the PropertyModification only has a reference to the prefab object. In a more complex prefab, with eventually nested prefabs, variants etc… I dont see a way to access the corresponding instance property to call RevertPropertyOverride.

Another way to do this would be traversing all SerializedProperties of a prefab instance and check whether SerializedProperty.prefabOverride is true. But then I dont see any way to access the prefab value which is overridden for comparison.

Any ideas how to do this?

thanks!

I know is late but I had the same problem and I found the solution on this answer. Maybe it will help others:

You can remove your modifications you want to revert from the list, then apply the modification list to your prefab instance instance.

You can use GetCorrespondingObjectFromSource and then find the same SerializedProperty on that object to get the Prefab Asset value.

I think this is a bug. The documentation states that the target points to an instance, but in reality, it points to a prefab.