{"record":{"id":"9172565495dbc921","repo":"Unity-Technologies/UnityCsReference","slug":"can-t-apply-to-a-model-prefab","errorCode":null,"errorMessage":"Can't apply to a Model Prefab","messagePattern":"Can't apply to a Model Prefab","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.cs","lineNumber":2162,"sourceCode":"                return null;\n            }\n\n            if (action == InteractionMode.UserAction)\n            {\n                Undo.RecordCreatedObject(GetPrefabInstanceHandle(instanceRoot), actionName);\n            }\n\n            return assetRoot;\n        }\n\n        internal static void ApplyPrefabInstance(GameObject instance)\n        {\n            if (instance == null)\n                throw new ArgumentNullException(nameof(instance));\n\n            // Include model check even though models are also immutable, since we can give a more clear exception message.\n            if (IsPartOfModelPrefab(instance))\n                throw new ArgumentException(\"Can't apply to a Model Prefab\");\n\n            if (IsPartOfImmutablePrefab(instance))\n                throw new ArgumentException(\"Can't apply to an immutable Prefab\");\n\n            if (!IsPartOfNonAssetPrefabInstance(instance))\n                throw new ArgumentException(\"Provided GameObject is not a Prefab instance\");\n\n            var root = GetOutermostPrefabInstanceRoot(instance);\n            if (root != instance)\n                throw new ArgumentException(\"GameObject to save Prefab from must be a Prefab root\");\n\n            var assetObject = GetCorrespondingObjectFromSource(instance);\n            string path = AssetDatabase.GetAssetPath(assetObject);\n\n            SaveAsPrefabAssetArgumentCheck(instance, path, true);\n\n            Internal_CallPrefabInstanceApplying(instance);\n","sourceCodeStart":2144,"sourceCodeEnd":2180,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.cs#L2144-L2180","documentation":"Thrown by ApplyPrefabInstance when the instance is part of a Model Prefab (imported from a 3D model file like FBX or OBJ). Model Prefabs are immutable because their structure is driven by the source model import; overrides cannot be applied back to them.","triggerScenarios":"Calling ApplyPrefabInstance on a GameObject whose hierarchy originates from a model-imported Prefab (IsPartOfModelPrefab returns true). The model check runs before the general immutability check to provide a clearer message.","commonSituations":"Developer selects a node inside an imported FBX hierarchy and tries to apply a Prefab override. Attempting to apply changes back to a model asset rather than creating a separate Prefab variant.","solutions":["Create a separate Prefab from the model instance (SaveAsPrefabAsset) and apply overrides to that new Prefab instead.","Use a Prefab Variant based on the model if you need structured override relationships.","If model structure must change, edit the source model file and reimport, not via ApplyPrefabInstance."],"exampleFix":"// before\nPrefabUtility.ApplyPrefabInstance(modelInstanceChild);\n// after\n// Create a standalone Prefab from the model instance first\nGameObject newPrefab = PrefabUtility.SaveAsPrefabAsset(\n    modelInstanceChild, \"Assets/MyPrefab.prefab\");\nPrefabUtility.ApplyPrefabInstance(newPrefab);","handlingStrategy":"validation","validationCode":"if (PrefabUtility.IsPartOfModelPrefab(instance))\n{ Debug.LogError(\"Cannot apply to a Model Prefab; create a separate Prefab.\"); return; }\nPrefabUtility.ApplyPrefabInstance(instance);","typeGuard":"static bool IsApplyablePrefabType(GameObject go) =>\n    go != null &&\n    !PrefabUtility.IsPartOfModelPrefab(go) &&\n    !PrefabUtility.IsPartOfImmutablePrefab(go) &&\n    PrefabUtility.IsPartOfNonAssetPrefabInstance(go);","tryCatchPattern":null,"preventionTips":["Never call ApplyPrefabInstance on model-imported hierarchies.","Create standalone Prefabs from model instances before applying.","Check IsPartOfModelPrefab in editor tools that operate on selections."],"tags":["unity","prefab","model-prefab","immutable","apply"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}