Unity-Technologies/UnityCsReference · error · ArgumentException
Cannot apply added GameObject. GameObject
Error message
Cannot apply added GameObject. GameObject '{go.name}' is not an added GameObject override on a Prefab instance. What it means
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.
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.
Example fix
// before
PrefabUtility.ApplyAddedGameObjects(selectedGos, path, mode);
// after
var added = selectedGos.Where(PrefabUtility.IsAddedGameObjectOverride).ToArray();
if (added.Length > 0)
PrefabUtility.ApplyAddedGameObjects(added, path, mode); Defensive patterns
Strategy: validation
Validate before calling
gameObjects = gameObjects?.Where(PrefabUtility.IsAddedGameObjectOverride).ToArray(); if (gameObjects == null || gameObjects.Length == 0) return;
Type guard
static bool IsAddedOverride(GameObject go) =>
go != null && PrefabUtility.IsAddedGameObjectOverride(go); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Confusing original prefab children with added overrides; passing the instance root; selecting siblings that were not actually added by the user.
Related errors
- Cannot revert added GameObject. GameObject is not an added…
- Array is invalid.
- Cannot apply added GameObjects. GameObjects array is null.
- Cannot revert added GameObject. GameObject is null.
- Cannot save as new prefab using the same path
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/c7f884506401018f.
Report an issue: GitHub.
Appendix: source
Thrown at Editor/Mono/Prefabs/PrefabUtility.cs:1658
}
public static void ApplyAddedGameObjects(GameObject[] gameObjects, string assetPath, InteractionMode action)
{
DateTime startTime = DateTime.UtcNow;
if (gameObjects == null)
throw new ArgumentNullException(nameof(gameObjects), "Cannot apply added GameObjects. GameObjects array is null.");
if (gameObjects.Length == 0)
throw new ArgumentException(nameof(gameObjects), "No GameObjects in array.");
foreach (GameObject go in gameObjects)
{
if (go == null)
throw new ArgumentException(nameof(go), "Input GameObject is null.");
if (!IsAddedGameObjectOverride(go))
throw new ArgumentException(nameof(go), $"Cannot apply added GameObject. GameObject '{go.name}' is not an added GameObject override on a Prefab instance.");
ThrowExceptionIfInstanceIsPersistent(go);
}
if (gameObjects.Length > 1 && !HasSameParent(gameObjects))
throw new ArgumentException(nameof(gameObjects), "ApplyAddedGameObjects requires that GameObjects share the same parent.");
GameObject gameObject = gameObjects[0];
Transform instanceParent = gameObject.transform.parent;
if (instanceParent == null)
return;
GameObject prefabSourceGameObjectParent = GetCorrespondingObjectFromSourceAtPath(instanceParent.gameObject, assetPath);
if (prefabSourceGameObjectParent == null)
return;
var instanceRoot = GetOutermostPrefabInstanceRoot(instanceParent);
if (instanceRoot == null)View on GitHub (pinned to 225b0fbdb5)