{"record":{"id":"9957311411c21240","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-revert-overriden-properties-in-animation-mo","errorCode":null,"errorMessage":"Cannot revert overriden properties in Animation Mode.","messagePattern":"Cannot revert overriden properties in Animation Mode\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.cs","lineNumber":589,"sourceCode":"            if (referencedObject != null)\n            {\n                property.objectReferenceValue = referencedObject;\n            }\n        }\n\n        static bool WarnIfInAnimationMode(OverrideOperation overrideOperation, InteractionMode action)\n        {\n            if (!AnimationMode.InAnimationMode())\n                return false;\n\n            if (action == InteractionMode.AutomatedAction)\n            {\n                switch (overrideOperation)\n                {\n                    case OverrideOperation.Apply:\n                        throw new InvalidOperationException(\"Cannot apply overriden properties in Animation Mode.\");\n                    case OverrideOperation.Revert:\n                        throw new InvalidOperationException(\"Cannot revert overriden properties in Animation Mode.\");\n                }\n            }\n            else if (action == InteractionMode.UserAction)\n            {\n                var message = L10n.Tr(\"Overriden properties cannot be applied or reverted when in Animation Mode.\\n\\nDisable Animation Mode and try again.\");\n                switch (overrideOperation)\n                {\n                    case OverrideOperation.Apply:\n                        EditorUtility.DisplayDialog(\n                            L10n.Tr(\"Cannot apply property override to Prefab\"),\n                            message,\n                            L10n.Tr(\"OK\"));\n                        break;\n                    case OverrideOperation.Revert:\n                        EditorUtility.DisplayDialog(\n                            L10n.Tr(\"Cannot revert property override\"),\n                            message,\n                            L10n.Tr(\"OK\"));","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.cs#L571-L607","documentation":"Thrown by WarnIfInAnimationMode when a Revert override operation is attempted during Animation Mode with InteractionMode.AutomatedAction. Reverting overrides while Animation Mode samples them would desync the preview, so the automated path raises InvalidOperationException('Cannot revert overriden properties in Animation Mode.').","triggerScenarios":"Calling RevertObjectOverride / RevertAddedComponent-family methods with InteractionMode.AutomatedAction while AnimationMode.InAnimationMode() is true.","commonSituations":"Automation pipelines that revert overrides on a schedule overlapping an animation preview; tooling that wraps revert in batch jobs without checking editor state; timeline preview sessions.","solutions":["Stop Animation Mode first: AnimationMode.StopAnimationMode();","Gate automated reverts with: if (!AnimationMode.InAnimationMode()) Revert...;","Switch to InteractionMode.UserAction for interactive use where a dialog is acceptable."],"exampleFix":"// before\nPrefabUtility.RevertObjectOverride(obj, InteractionMode.AutomatedAction);\n\n// after\nif (AnimationMode.InAnimationMode())\n    AnimationMode.StopAnimationMode();\nPrefabUtility.RevertObjectOverride(obj, InteractionMode.AutomatedAction);","handlingStrategy":"validation","validationCode":"if (AnimationMode.InAnimationMode())\n    AnimationMode.StopAnimationMode();\nPrefabUtility.RevertObjectOverride(obj, InteractionMode.AutomatedAction);","typeGuard":"static bool CanRevertOverridesNow() => !AnimationMode.InAnimationMode();","tryCatchPattern":"try { PrefabUtility.RevertObjectOverride(obj, InteractionMode.AutomatedAction); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Animation Mode\"))\n{ Debug.LogWarning(\"Skipped revert: Animation Mode active.\"); }","preventionTips":["Check AnimationMode state before automated revert calls.","Ensure preview/record sessions are stopped before batch override operations.","Use InteractionMode.UserAction when a blocking dialog is acceptable."],"tags":["prefab","animation-mode","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}