Script for Revert Value to Prefab

I have an unusual issue that I’m trying to solve with an Editor script fixing tool. Basically I have many instances of an animated mesh, imported from an FBX object, across multiple scenes. For some reason, the skinned mesh renderer component of a child object of that prefab has, after it’s been imported, had its Materials property baked in. As in, changes to the underlying FBX object to change the materials are not reflected in the many instances of the object. Not the other properties (like quality, light probes, etc.), just the Materials array. I’ve no idea why that is, I can’t recreate when it happens, although I do hand off these scenes to artists to edit and it may be something they’re doing. It doesn’t really bother me, although it would also be nice to find out why.

Anyway, to fix this issue, I use scene filtering to get a list of the the objects with the mesh renderer component which is faulty. In the inspector, I simply right-click the Materials array and do ‘Revert Value to Prefab’, and it reverts to using the correct materials straight from the prefab. My problem: there are dozens of these instances, across a score of scenes. I can’t bulk select the instances and do it, because the ‘Revert Value to Prefab’ context option doesn’t appear.

I do have an editor helper script that can easily iterate over the instances in the scene, but the only way I have of reverting to the prefab values is the object-wide PrefabUtility.RevertPrefabInstance(theObject). That’s not a workable solution, because there are other child objects added to the instances that I must preserve. I need a per-property revert to prefab.

So my question is: is the “Revert Value to Prefab” functionality exposed to the scripting system somehow, and if so, how?

SerializedProperty sp = new SerializedObject(theComponent).FindProperty(“thePropertyName”);
sp.prefabOverride = false;
sp.serializedObject.ApplyModifiedProperties();