{"record":{"id":"8d1e9f9b9b606231","repo":"Unity-Technologies/UnityCsReference","slug":"can-t-save-prefab-instance-with-missing-asset-and","errorCode":null,"errorMessage":"Can't save Prefab instance with missing asset and scene backup as a Prefab. You may unpack the instance and save the unpacked GameObjects as a Prefab.","messagePattern":"Can't save Prefab instance with missing asset and scene backup as a Prefab\\. You may unpack the instance and save the unpacked GameObjects as a Prefab\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.cs","lineNumber":2086,"sourceCode":"            }\n        }\n\n        private static void SaveAsPrefabAssetArgumentCheck(GameObject instanceRoot, string path, bool connectToInstance)\n        {\n            if (instanceRoot == null)\n                throw new ArgumentNullException(\"Parameter root is null\");\n\n            if (EditorUtility.IsPersistent(instanceRoot) && connectToInstance)\n                throw new ArgumentException(\"Can't save persistent Objects and connect them to the saved Prefab\");\n\n            if (IsPartOfNonAssetPrefabInstance(instanceRoot))\n            {\n                // A PrefabInstance with missing asset can be correctly restored only if CorrespondingObjects info is available\n                // CorrespondingObject info is available when a PrefabInstance with missing asset was merged before deleting the asset (kNormalMerge) or when it has a scene backup (kMergedAsMissingWithSceneBackup)\n                var mergeStatus = GetMergeStatus(instanceRoot);\n                var hasCorrespondingSourceObjectInfo = mergeStatus == MergeStatus.NormalMerge || mergeStatus == MergeStatus.MergedAsMissingWithSceneBackup;\n                if (IsPrefabAssetMissing(instanceRoot) && !hasCorrespondingSourceObjectInfo)\n                    throw new ArgumentException(\"Can't save Prefab instance with missing asset and scene backup as a Prefab. You may unpack the instance and save the unpacked GameObjects as a Prefab.\");\n            }\n\n            var actualInstanceRoot = GetOutermostPrefabInstanceRoot(instanceRoot);\n            if (actualInstanceRoot)\n            {\n                if (actualInstanceRoot != instanceRoot)\n                    throw new ArgumentException(\"Can't save part of a Prefab instance as a Prefab\");\n            }\n\n            ValidatePath(instanceRoot, path);\n        }\n\n        private static void ReplacePrefabArgumentCheck(GameObject root, string path)\n        {\n            if (root == null)\n                throw new ArgumentNullException(\"Parameter root is null\");\n\n            ValidatePath(root, path);","sourceCodeStart":2068,"sourceCodeEnd":2104,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.cs#L2068-L2104","documentation":"Thrown when the instanceRoot is part of a non-asset Prefab instance whose source asset has been deleted (IsPrefabAssetMissing) AND there is no CorrespondingObject info available (merge status is not NormalMerge or MergedAsMissingWithSceneBackup). Without corresponding-object info, Unity cannot reconstruct the instance when saving it back as a Prefab.","triggerScenarios":"A Prefab instance in a scene whose source .prefab asset was deleted. The instance was not properly merged or backed up before deletion, so it has no corresponding source references to map overrides against.","commonSituations":"A teammate deleted a Prefab asset but left scene instances referencing it. Deleting a Prefab from the project without first unpacking all its instances. Git merge or asset migration that drops a .prefab file while scenes still reference it.","solutions":["Unpack the instance: PrefabUtility.UnpackPrefabInstance(instanceRoot, PrefabUnpackMode.Completely, InteractionMode.UserAction); then save the unpacked GameObjects as a new Prefab.","Restore the missing .prefab asset (from version control or backup) so the instance resolves again.","Audit scenes for missing-Prefab instances after deleting assets using FindObjectsOfType and IsPrefabAssetMissing."],"exampleFix":"// before\nPrefabUtility.SaveAsPrefabAsset(missingInstanceRoot, \"Assets/Rebuilt.prefab\");\n// after\nPrefabUtility.UnpackPrefabInstance(missingInstanceRoot,\n    PrefabUnpackMode.Completely, InteractionMode.UserAction);\nPrefabUtility.SaveAsPrefabAsset(missingInstanceRoot, \"Assets/Rebuilt.prefab\");","handlingStrategy":"validation","validationCode":"void SaveOrUnpackMissing(GameObject go, string path)\n{\n    if (PrefabUtility.IsPartOfNonAssetPrefabInstance(go) &&\n        PrefabUtility.IsPrefabAssetMissing(go))\n    {\n        var status = PrefabUtility.GetMergeStatus(go);\n        bool hasInfo = status == MergeStatus.NormalMerge ||\n                       status == MergeStatus.MergedAsMissingWithSceneBackup;\n        if (!hasInfo)\n        {\n            PrefabUtility.UnpackPrefabInstance(go,\n                PrefabUnpackMode.Completely, InteractionMode.UserAction);\n        }\n    }\n    PrefabUtility.SaveAsPrefabAsset(go, path);\n}","typeGuard":"static bool IsMissingInstanceRecoverable(GameObject go)\n{\n    if (!PrefabUtility.IsPrefabAssetMissing(go)) return true;\n    var s = PrefabUtility.GetMergeStatus(go);\n    return s == MergeStatus.NormalMerge ||\n           s == MergeStatus.MergedAsMissingWithSceneBackup;\n}","tryCatchPattern":null,"preventionTips":["Before deleting a Prefab asset, unpack all its scene instances.","Audit scenes with IsPrefabAssetMissing after asset deletions.","Restore missing Prefabs from version control rather than forcing saves."],"tags":["unity","prefab","missing-asset","argument-check"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}