Unity-Technologies/UnityCsReference · error · ArgumentException

Input is from a Prefab asset, this is not supported. Input G

Error message

Input is from a Prefab asset, this is not supported. Input GameObject: 

What it means

Thrown by ThrowIfInvalidArgumentsForConvertToPrefabInstance when EditorUtility.IsPersistent(plainGameObject) is true. The input must be a plain scene GameObject, not an asset stored on disk. Passing a Prefab asset root (loaded from the Asset Database) is rejected because ConvertToPrefabInstance operates on live scene objects.

Source

Thrown at Editor/Mono/Prefabs/PrefabUtility.cs:2355

            }

            if (mode == InteractionMode.UserAction)
                Undo.FlushTrackedObjects();
        }

        internal static void ThrowIfInvalidArgumentsForConvertToPrefabInstance(GameObject plainGameObject, GameObject prefabAssetRoot, bool checkValidAsset, InteractionMode mode)
        {
            if (plainGameObject == null)
                throw new ArgumentNullException(nameof(plainGameObject));

            if (prefabAssetRoot == null)
                throw new ArgumentNullException(nameof(prefabAssetRoot));

            if (IsPartOfNonAssetPrefabInstance(plainGameObject))
                throw new InvalidOperationException(string.Format("Input '{0}' is not a plain GameObject, it is already a Prefab instance. Use ReplacePrefabAssetOfPrefabInstance() instead.", plainGameObject.name));

            if (EditorUtility.IsPersistent(plainGameObject))
                throw new ArgumentException("Input is from a Prefab asset, this is not supported. Input GameObject: " + plainGameObject.name, nameof(plainGameObject));

            if (checkValidAsset)
                ThrowIfInvalidAssetForReplacePrefabInstance(prefabAssetRoot, mode);

            if (plainGameObject.transform.GetType() != prefabAssetRoot.transform.GetType())
                throw new InvalidOperationException(string.Format("Cannot convert the GameObject '{0}' with root transform of type {1} with a Prefab asset with root transform of type {2}. Transform types must match.", plainGameObject.name, plainGameObject.transform.GetType().Name, prefabAssetRoot.transform.GetType().Name));

            // Prefab Mode and EditPrefabContents scope handling
            if (PrefabStageUtility.IsGameObjectThePrefabRootInAnyPrefabStage(plainGameObject) || (EditorSceneManager.IsPreviewSceneObject(plainGameObject) && plainGameObject.transform.parent == null))
                throw new InvalidOperationException("Replacing the root GameObject in a Prefab with a Prefab instance is not supported since it will break all overrides for existing instances of this Prefab, including their positions and rotations." + plainGameObject.name);

            if (plainGameObject.hideFlags.HasFlag(HideFlags.DontSaveInEditor) || plainGameObject.transform.hideFlags.HasFlag(HideFlags.DontSaveInEditor))
                throw new ArgumentException("Input GameObject is using the HideFlags.DontSaveInEditor flag which is not supported when converting to Prefab instance: GameObject: " + plainGameObject.name, nameof(plainGameObject));

            if (mode == InteractionMode.UserAction)
            {
                // Recording undo does not handle missing scripts
                var gameObjectsWithInvalidScript = FindGameObjectsWithInvalidComponent(plainGameObject);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Operate on a scene-level GameObject, not an asset reference.
  2. If the asset is a plain .prefab you want to edit, use PrefabUtility.LoadPrefabContents / SaveAsPrefabAsset instead.
  3. Guard: if (EditorUtility.IsPersistent(obj)) return;

Example fix

// before
var assetGo = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Plain.prefab");
PrefabUtility.ConvertToPrefabInstance(assetGo, prefabAsset, settings, mode);

// after — load contents, modify, save
var contents = PrefabUtility.LoadPrefabContents("Assets/Plain.prefab");
// ... operate on contents in the preview scene ...
PrefabUtility.SaveAsPrefabAsset(contents, "Assets/Plain.prefab");
PrefabUtility.UnloadPrefabContents(contents);
Defensive patterns

Strategy: validation

Validate before calling

if (EditorUtility.IsPersistent(plainGameObject))
{
    Debug.LogError("Input is a persistent asset, not a scene GameObject. Use LoadPrefabContents/SaveAsPrefabAsset instead.");
    return;
}
PrefabUtility.ConvertToPrefabInstance(plainGameObject, prefabAssetRoot, settings, mode);

Type guard

static bool IsSceneGameObject(GameObject obj)
{
    return obj != null && !EditorUtility.IsPersistent(obj);
}

Prevention

When it happens

Trigger: Loading a GameObject via AssetDatabase.LoadAssetAtPath or Resources.Load and passing it to ConvertToPrefabInstance. Using AssetDatabase.FindAssets to enumerate objects and calling convert on the asset references.

Common situations: Confusing a Prefab asset (on disk) with a plain GameObject (in scene). Code that processes project-level assets instead of scene instances.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/66a89cb29e1124c3. Report an issue: GitHub.