Unity-Technologies/UnityCsReference · error · ArgumentException

Can't save a Model Prefab

Error message

Can't save a Model Prefab

What it means

SavePrefabAsset throws ArgumentException for model prefabs — prefabs imported from a 3D model file (FBX, DAE, OBJ, etc.). Model prefabs are immutable because their contents are regenerated from the source asset on reimport, so saving would be overwritten and is disallowed. The model check runs before the generic immutable check to give a clearer message.

Source

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

            var assetObject = SaveAsPrefabAsset(empty, path, out success);
            Object.DestroyImmediate(empty);
            return PrefabUtility.GetPrefabObject(assetObject);
        }

        public static GameObject SavePrefabAsset(GameObject asset)
        {
            bool savedSuccesfully;
            return SavePrefabAsset(asset, out savedSuccesfully);
        }

        public static GameObject SavePrefabAsset(GameObject asset, out bool savedSuccessfully)
        {
            if (asset == null)
                throw new ArgumentNullException("Parameter prefabAssetGameObject is null");

            // Include model check even though models are also immutable, since we can give a more clear exception message.
            if (IsPartOfModelPrefab(asset))
                throw new ArgumentException("Can't save a Model Prefab");

            if (IsPartOfImmutablePrefab(asset))
                throw new ArgumentException("Can't save an immutable Prefab");

            string path = AssetDatabase.GetAssetPath(asset);
            if (String.IsNullOrEmpty(path))
                throw new ArgumentException("Can't save a Prefab instance");

            var root = asset.transform.root.gameObject;
            if (root != asset)
                throw new ArgumentException("GameObject to save Prefab from must be a Prefab root");

            return SavePrefabAsset_Internal(root, out savedSuccessfully);
        }

        internal static void ValidatePath(GameObject instanceRoot, string path)
        {
            if (String.IsNullOrEmpty(path))

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Create a prefab variant of the model prefab and edit the variant, or unpack the model prefab into a regular prefab under Assets/.
  2. Edit the source model file in the external DCC tool and reimport, instead of saving in Unity.
  3. Filter with !PrefabUtility.IsPartOfModelPrefab(asset) before attempting to save.

Example fix

// before
PrefabUtility.SavePrefabAsset(modelPrefabRoot);

// after
if (PrefabUtility.IsPartOfModelPrefab(modelPrefabRoot))
    PrefabUtility.SaveAsPrefabAsset(modelPrefabRoot, "Assets/MyModelCopy.prefab");
else
    PrefabUtility.SavePrefabAsset(modelPrefabRoot);
Defensive patterns

Strategy: validation

Validate before calling

if (PrefabUtility.IsPartOfModelPrefab(asset))
{
    // create a variant or copy instead
    return;
}

Type guard

static bool IsSaveablePrefab(GameObject asset) =>
    asset != null && !PrefabUtility.IsPartOfModelPrefab(asset)
    && !PrefabUtility.IsPartOfImmutablePrefab(asset);

Prevention

When it happens

Trigger: Calling SavePrefabAsset on a GameObject that is part of a model-imported prefab (IsPartOfModelPrefab returns true).

Common situations: Selecting an imported 3D model's hierarchy and attempting to save edits back to it; scripts that operate on arbitrary prefab assets without filtering model prefabs.

Related errors


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