Unity-Technologies/UnityCsReference · error · ArgumentException
Can't apply to a Model Prefab
Error message
Can't apply to a Model Prefab
What it means
Thrown by ApplyPrefabInstance when the instance is part of a Model Prefab (imported from a 3D model file like FBX or OBJ). Model Prefabs are immutable because their structure is driven by the source model import; overrides cannot be applied back to them.
Source
Thrown at Editor/Mono/Prefabs/PrefabUtility.cs:2162
return null;
}
if (action == InteractionMode.UserAction)
{
Undo.RecordCreatedObject(GetPrefabInstanceHandle(instanceRoot), actionName);
}
return assetRoot;
}
internal static void ApplyPrefabInstance(GameObject instance)
{
if (instance == null)
throw new ArgumentNullException(nameof(instance));
// Include model check even though models are also immutable, since we can give a more clear exception message.
if (IsPartOfModelPrefab(instance))
throw new ArgumentException("Can't apply to a Model Prefab");
if (IsPartOfImmutablePrefab(instance))
throw new ArgumentException("Can't apply to an immutable Prefab");
if (!IsPartOfNonAssetPrefabInstance(instance))
throw new ArgumentException("Provided GameObject is not a Prefab instance");
var root = GetOutermostPrefabInstanceRoot(instance);
if (root != instance)
throw new ArgumentException("GameObject to save Prefab from must be a Prefab root");
var assetObject = GetCorrespondingObjectFromSource(instance);
string path = AssetDatabase.GetAssetPath(assetObject);
SaveAsPrefabAssetArgumentCheck(instance, path, true);
Internal_CallPrefabInstanceApplying(instance);
View on GitHub (pinned to 225b0fbdb5)
Solutions
- Create a separate Prefab from the model instance (SaveAsPrefabAsset) and apply overrides to that new Prefab instead.
- Use a Prefab Variant based on the model if you need structured override relationships.
- If model structure must change, edit the source model file and reimport, not via ApplyPrefabInstance.
Example fix
// before
PrefabUtility.ApplyPrefabInstance(modelInstanceChild);
// after
// Create a standalone Prefab from the model instance first
GameObject newPrefab = PrefabUtility.SaveAsPrefabAsset(
modelInstanceChild, "Assets/MyPrefab.prefab");
PrefabUtility.ApplyPrefabInstance(newPrefab); Defensive patterns
Strategy: validation
Validate before calling
if (PrefabUtility.IsPartOfModelPrefab(instance))
{ Debug.LogError("Cannot apply to a Model Prefab; create a separate Prefab."); return; }
PrefabUtility.ApplyPrefabInstance(instance); Type guard
static bool IsApplyablePrefabType(GameObject go) =>
go != null &&
!PrefabUtility.IsPartOfModelPrefab(go) &&
!PrefabUtility.IsPartOfImmutablePrefab(go) &&
PrefabUtility.IsPartOfNonAssetPrefabInstance(go); Prevention
- Never call ApplyPrefabInstance on model-imported hierarchies.
- Create standalone Prefabs from model instances before applying.
- Check IsPartOfModelPrefab in editor tools that operate on selections.
When it happens
Trigger: Calling ApplyPrefabInstance on a GameObject whose hierarchy originates from a model-imported Prefab (IsPartOfModelPrefab returns true). The model check runs before the general immutability check to provide a clearer message.
Common situations: Developer selects a node inside an imported FBX hierarchy and tries to apply a Prefab override. Attempting to apply changes back to a model asset rather than creating a separate Prefab variant.
Related errors
- Can't apply to an immutable Prefab
- Can't save a Model Prefab
- Can't save an immutable Prefab
- Value cannot be null. (Parameter 'instance')
- Provided GameObject is not a Prefab instance
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/9172565495dbc921.
Report an issue: GitHub.