Hi
I am trying to write an editor script which will revert mesh filters which have had their mesh changed. I want to use PrefabUtility.RevertPropertyOverride but I can’t get it to work. My code looks like this
var meshFilters = go.GetComponentsInChildren<MeshFilter>();
foreach (var mf in meshFilters)
{
var serializedObject = new UnityEditor.SerializedObject(mf);
var serializedProp = serializedObject.FindProperty("sharedMesh");
PrefabUtility.RevertPropertyOverride(mf.sharedMesh, InteractionMode.UserAction);
}
The problem is that serializedProp is always null. It seems not to like the fact that sharedMesh is actually a getter property on MeshFilter, not a field?
If I inspect SerializedObject in Visual Studio, I can see that it does have a sharedMesh property, but I can’t use that in the RevertPropertyOverride call, because it requires an actualy SerializedProperty, not the property itself.
Is there a way to get the sharedMesh property on the MeshFilter as a SerializedProperty - or is there some other way I can revert it on each prefab?
Thanks for any help