{"record":{"id":"52a4145c298d39aa","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-applyt-to-immutable-prefab-assetpath","errorCode":null,"errorMessage":"Cannot applyt to immutable prefab: {assetPath}","messagePattern":"Cannot applyt to immutable prefab: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.cs","lineNumber":1091,"sourceCode":"                }\n                else if (action == InteractionMode.UserAction)\n                {\n                    EditorUtility.DisplayDialog(title, errorMsg, L10n.Tr(\"OK\"));\n                }\n            }\n\n            return warnUser;\n        }\n\n        public static void ApplyObjectOverride(Object instanceComponentOrGameObject, string assetPath, InteractionMode action)\n        {\n            DateTime startTime = DateTime.UtcNow;\n\n            ThrowExceptionIfNotValidPrefabInstanceObject(instanceComponentOrGameObject, true);\n\n            var obj = GetCorrespondingObjectFromSourceAtPath(instanceComponentOrGameObject, assetPath);\n            if (IsPartOfImmutablePrefab(obj))\n                throw new ArgumentException($\"Cannot applyt to immutable prefab: {assetPath}\");\n\n            if (WarnIfInAnimationMode(OverrideOperation.Apply, action))\n                return;\n\n            if (action == InteractionMode.UserAction)\n            {\n                ApplyObjectOverride(instanceComponentOrGameObject, assetPath);\n\n                Component instanceComponent = instanceComponentOrGameObject as Component;\n                if (instanceComponent != null)\n                {\n                    Component coupledComponent = instanceComponent.GetCoupledComponent();\n                    if (coupledComponent != null)\n                        ApplyObjectOverride(coupledComponent, assetPath);\n                }\n            }\n            else\n            {","sourceCodeStart":1073,"sourceCodeEnd":1109,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.cs#L1073-L1109","documentation":"Thrown by ApplyObjectOverride when GetCorrespondingObjectFromSourceAtPath resolves the asset-side object and PrefabUtility.IsPartOfImmutablePrefab(obj) returns true. Immutable prefabs live in read-only locations (the package cache, built-in packages, or read-only assets) and cannot be written to, so applying an override back to them is rejected. Note the message contains a typo ('applyt') as shipped.","triggerScenarios":"Calling PrefabUtility.ApplyObjectOverride on an instance whose source prefab asset is inside the Packages folder cache (e.g. com.unity.*), a built-in module prefab, or any asset marked read-only; applying overrides from a prefab variant of an immutable base.","commonSituations":"Customizing prefabs sourced from an imported asset package without first copying them into Assets/; editor tools that bulk-apply overrides including instances of package-shipped prefabs; workflows that forget to make prefabs writable first.","solutions":["Make the prefab writable: copy the prefab asset out of Packages/<pkg> into Assets/ and repoint instances, or use a Prefab Variant instead of applying into the base.","Check PrefabUtility.IsPartOfImmutablePrefab(GetCorrespondingObjectFromSourceAtPath(obj, assetPath)) before applying and skip/redirect.","Ensure the target prefab asset lives under a writable Assets/ folder, not the read-only package cache."],"exampleFix":"// before\nPrefabUtility.ApplyObjectOverride(obj, assetPath, InteractionMode.AutomatedAction);\n\n// after\nvar src = PrefabUtility.GetCorrespondingObjectFromSourceAtPath(obj, assetPath);\nif (src != null && PrefabUtility.IsPartOfImmutablePrefab(src))\n    Debug.LogWarning($\"Skipping immutable prefab at {assetPath}\");\nelse\n    PrefabUtility.ApplyObjectOverride(obj, assetPath, InteractionMode.AutomatedAction);","handlingStrategy":"validation","validationCode":"var src = PrefabUtility.GetCorrespondingObjectFromSourceAtPath(obj, assetPath);\nif (src != null && PrefabUtility.IsPartOfImmutablePrefab(src))\n{\n    Debug.LogWarning($\"Cannot apply to immutable prefab: {assetPath}\");\n    return;\n}\nPrefabUtility.ApplyObjectOverride(obj, assetPath, action);","typeGuard":"static bool IsWritablePrefab(Object src)\n    => src == null || !PrefabUtility.IsPartOfImmutablePrefab(src);","tryCatchPattern":"try { PrefabUtility.ApplyObjectOverride(obj, assetPath, action); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"immutable prefab\"))\n{ Debug.LogWarning($\"Skipped immutable prefab: {assetPath}\"); }","preventionTips":["Copy package-shipped prefabs into a writable Assets/ folder before applying overrides.","Use Prefab Variants instead of editing read-only base prefabs.","Filter out immutable prefabs before bulk apply operations."],"tags":["prefab","immutable","packages","read-only"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}