Unity-Technologies/UnityCsReference · error · InvalidOperationException
Mismatching Objects: Cannot revert a single SerializeReferen
Error message
Mismatching Objects: Cannot revert a single SerializeReference field since the Prefab instance is referencing a new object compared to the Prefab Asset. This means that the entire object is considered an override, cannot revert parts of it. You can revert the root of the serialized reference or the entire component.
What it means
Thrown (AutomatedAction) / dialog (UserAction) during revert of a SerializeReference field when the instance's managedReferencePropertyPath differs from the asset's (object mismatch). Because the entire managed object is treated as an override, Unity cannot revert only part of it; you must revert the reference root or the whole component.
Source
Thrown at Editor/Mono/Prefabs/PrefabUtility.cs:1072
if (revertingNotPossible)
{
title = L10n.Tr("Mismatching Objects");
errorMsg = L10n.Tr("Cannot revert a single SerializeReference field since the Prefab instance is referencing a new object compared to the Prefab Asset.\n\nThis means that the entire object is considered an override, cannot revert parts of it.\n\nYou can revert the root of the serialized reference or the entire component.");
}
}
else
{
// Type mismatch:
title = L10n.Tr("Mismatching Types");
errorMsg = L10n.Tr("Cannot revert a parts of a SerializeReference property since the Prefab instance is referencing a different type compared to the Prefab Asset.\n\nYou can revert the root of the serialized reference or the entire component.");
}
bool warnUser = !string.IsNullOrEmpty(errorMsg);
if (warnUser)
{
if (action == InteractionMode.AutomatedAction)
{
throw new InvalidOperationException(title + ": " + errorMsg);
}
else if (action == InteractionMode.UserAction)
{
EditorUtility.DisplayDialog(title, errorMsg, L10n.Tr("OK"));
}
}
return warnUser;
}
public static void ApplyObjectOverride(Object instanceComponentOrGameObject, string assetPath, InteractionMode action)
{
DateTime startTime = DateTime.UtcNow;
ThrowExceptionIfNotValidPrefabInstanceObject(instanceComponentOrGameObject, true);
var obj = GetCorrespondingObjectFromSourceAtPath(instanceComponentOrGameObject, assetPath);
if (IsPartOfImmutablePrefab(obj))View on GitHub (pinned to 225b0fbdb5)
Solutions
- Revert the SerializeReference root field instead of a sub-field.
- Revert the entire component to restore the asset's reference identity.
- Pre-check instanceProperty.managedReferencePropertyPath == sourceProperty.managedReferencePropertyPath before attempting a sub-field revert.
Example fix
// before PrefabUtility.RevertPropertyOverride(instanceRoot, "ref.subField", InteractionMode.AutomatedAction); // after PrefabUtility.RevertPropertyOverride(instanceRoot, "ref", InteractionMode.AutomatedAction);
Defensive patterns
Strategy: validation
Validate before calling
var inst = new SerializedObject(instanceObj).FindProperty(path);
var src = new SerializedObject(assetObj).FindProperty(path);
if (inst != null && src != null &&
inst.managedReferencePropertyPath != src.managedReferencePropertyPath)
path = refRootPath; // revert at root instead
PrefabUtility.RevertPropertyOverride(instanceRoot, path, action); Type guard
static bool CanRevertSubField(SerializedProperty inst, SerializedProperty src)
=> inst != null && src != null &&
inst.managedReferencePropertyPath == src.managedReferencePropertyPath; Try / catch
try { PrefabUtility.RevertPropertyOverride(root, subPath, action); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Mismatching Objects"))
{ PrefabUtility.RevertPropertyOverride(root, refRootPath, action); } Prevention
- Revert the SerializeReference root when the instance references a different managed object.
- Compare managedReferencePropertyPath before attempting a sub-field revert.
- For polymorphic references, default to component-level revert.
When it happens
Trigger: Reverting a single SerializeReference sub-field via automation where the instance references a different managed object than the asset (revertingNotPossible == true).
Common situations: Polymorphic managed-reference fields where the instance swapped the referenced object; reverting after assigning a new managed reference instance; reverting nested fields of an inventory/stat system.
Related errors
- Mismatching Types: Cannot revert a parts of a SerializeRefer
- Mismatching Objects: Cannot apply SerializeReference field s
- Mismatching Types: Cannot apply a SerializeReference sub fie
- Cannot apply added GameObject. GameObject '{go.name}' is not
- Cannot revert added GameObject. GameObject is not an added G
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/a9b378da779c27fa.
Report an issue: GitHub.