{"record":{"id":"c7f884506401018f","repo":"Unity-Technologies/UnityCsReference","slug":"cannot-apply-added-gameobject-gameobject-go-nam","errorCode":null,"errorMessage":"Cannot apply added GameObject. GameObject '{go.name}' is not an added GameObject override on a Prefab instance.","messagePattern":"Cannot apply added GameObject\\. GameObject '(.+?)' is not an added GameObject override on a Prefab instance\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Prefabs/PrefabUtility.cs","lineNumber":1658,"sourceCode":"        }\n\n        public static void ApplyAddedGameObjects(GameObject[] gameObjects, string assetPath, InteractionMode action)\n        {\n            DateTime startTime = DateTime.UtcNow;\n\n            if (gameObjects == null)\n                throw new ArgumentNullException(nameof(gameObjects), \"Cannot apply added GameObjects. GameObjects array is null.\");\n\n            if (gameObjects.Length == 0)\n                throw new ArgumentException(nameof(gameObjects), \"No GameObjects in array.\");\n\n            foreach (GameObject go in gameObjects)\n            {\n                if (go == null)\n                    throw new ArgumentException(nameof(go), \"Input GameObject is null.\");\n\n                if (!IsAddedGameObjectOverride(go))\n                    throw new ArgumentException(nameof(go), $\"Cannot apply added GameObject. GameObject '{go.name}' is not an added GameObject override on a Prefab instance.\");\n\n                ThrowExceptionIfInstanceIsPersistent(go);\n            }\n\n            if (gameObjects.Length > 1 && !HasSameParent(gameObjects))\n                throw new ArgumentException(nameof(gameObjects), \"ApplyAddedGameObjects requires that GameObjects share the same parent.\");\n\n            GameObject gameObject = gameObjects[0];\n            Transform instanceParent = gameObject.transform.parent;\n            if (instanceParent == null)\n                return;\n\n            GameObject prefabSourceGameObjectParent = GetCorrespondingObjectFromSourceAtPath(instanceParent.gameObject, assetPath);\n            if (prefabSourceGameObjectParent == null)\n                return;\n\n            var instanceRoot = GetOutermostPrefabInstanceRoot(instanceParent);\n            if (instanceRoot == null)","sourceCodeStart":1640,"sourceCodeEnd":1676,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Prefabs/PrefabUtility.cs#L1640-L1676","documentation":"Each element must be an 'added GameObject override' — a GameObject that was added to a prefab instance and does not exist in the source prefab asset. Verified via PrefabUtility.IsAddedGameObjectOverride(go). Applying an object that is not an addition is meaningless and is rejected.","triggerScenarios":"Passing a GameObject that exists in the source prefab (an original child), a prefab instance root, or a non-prefab object that happens to live inside the instance hierarchy.","commonSituations":"Confusing original prefab children with added overrides; passing the instance root; selecting siblings that were not actually added by the user.","solutions":["Check PrefabUtility.IsAddedGameObjectOverride(go) before adding the object to the array.","Obtain only legitimate additions via PrefabUtility.GetAddedGameObjects(instanceRoot) or by inspecting OverrideAddedComponents/added objects.","When unsure of override status, query GetPrefabOverrideStatus or HasPrefabOverride to classify first."],"exampleFix":"// before\nPrefabUtility.ApplyAddedGameObjects(selectedGos, path, mode);\n\n// after\nvar added = selectedGos.Where(PrefabUtility.IsAddedGameObjectOverride).ToArray();\nif (added.Length > 0)\n    PrefabUtility.ApplyAddedGameObjects(added, path, mode);","handlingStrategy":"validation","validationCode":"gameObjects = gameObjects?.Where(PrefabUtility.IsAddedGameObjectOverride).ToArray();\nif (gameObjects == null || gameObjects.Length == 0) return;","typeGuard":"static bool IsAddedOverride(GameObject go) =>\n    go != null && PrefabUtility.IsAddedGameObjectOverride(go);","tryCatchPattern":null,"preventionTips":["Source the apply list from PrefabUtility.GetAddedGameObjects(instanceRoot) to guarantee only additions.","Classify candidates with IsAddedGameObjectOverride before adding to the batch.","Do not assume all children of an instance are additions; originals are not overridable this way."],"tags":["prefab","unity","override","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}