Unity-Technologies/UnityCsReference · error · ArgumentException
Prefab not found at path {prefabAssetPath}
Error message
Prefab not found at path {prefabAssetPath} What it means
Thrown by PrefabStageUtility.OpenPrefab when AssetDatabase.LoadMainAssetAtPath(prefabAssetPath) returns null, meaning no asset exists at the given path. This validates that the prefab file actually exists in the project before attempting to open a stage for it.
Source
Thrown at Editor/Mono/SceneManagement/StageManager/PrefabStage/PrefabStageUtility.cs:99
public static PrefabStage OpenPrefab(string prefabAssetPath, GameObject openedFromInstance, PrefabStage.Mode prefabStageMode)
{
return OpenPrefab(prefabAssetPath, openedFromInstance, prefabStageMode, StageNavigationManager.Analytics.ChangeType.EnterViaUnknown);
}
internal static PrefabStage OpenPrefab(string prefabAssetPath, GameObject openedFromInstance, PrefabStage.Mode prefabStageMode, StageNavigationManager.Analytics.ChangeType changeTypeAnalytics)
{
if (string.IsNullOrEmpty(prefabAssetPath))
throw new ArgumentNullException(nameof(prefabAssetPath));
if (openedFromInstance != null && !PrefabUtility.IsPartOfPrefabInstance(openedFromInstance))
throw new ArgumentException("GameObject must be part of a Prefab instance, or null.", nameof(openedFromInstance));
if (!prefabAssetPath.EndsWith(".prefab", StringComparison.OrdinalIgnoreCase))
throw new ArgumentException("Incorrect file extension: " + prefabAssetPath + ". Must be '.prefab'", nameof(prefabAssetPath));
if (AssetDatabase.LoadMainAssetAtPath(prefabAssetPath) == null)
throw new ArgumentException("Prefab not found at path " + prefabAssetPath, nameof(prefabAssetPath));
return OpenPrefabMode(prefabAssetPath, openedFromInstance, prefabStageMode, changeTypeAnalytics);
}
static PrefabStage GetExistingPrefabStage(string prefabAssetPath, GameObject openedFromInstance, PrefabStage.Mode prefabStageMode)
{
var stageHistory = StageNavigationManager.instance.stageHistory;
for (int i = 1; i < stageHistory.Count; i++)
{
var prefabStage = stageHistory[i] as PrefabStage;
if (prefabStage != null && prefabStage.assetPath == prefabAssetPath)
{
// If PrefabStage.Mode did not match on existing PrefabStage we do not reuse the stage
// so we create a new PrefabStage with the correct mode
if (prefabStage.mode == prefabStageMode)
return prefabStage;
}
}View on GitHub (pinned to 225b0fbdb5)
Solutions
- Verify the asset exists with AssetDatabase.LoadMainAssetAtPath before calling OpenPrefab.
- Use AssetDatabase.FindAssets or GUID-based lookups to resolve the path dynamically.
- Refresh the AssetDatabase if the asset was recently added.
Example fix
// before
PrefabStageUtility.OpenPrefab(path, null, mode);
// after
if (AssetDatabase.LoadMainAssetAtPath(path) != null)
PrefabStageUtility.OpenPrefab(path, null, mode);
else
Debug.LogError($"Prefab not found at {path}"); Defensive patterns
Strategy: validation
Validate before calling
bool PrefabExists(string path)
{
return !string.IsNullOrEmpty(path) && AssetDatabase.LoadMainAssetAtPath(path) != null;
} Prevention
- Resolve asset paths via AssetDatabase.GUIDToAssetPath rather than hardcoding.
- Call AssetDatabase.Refresh() before looking up recently added assets.
When it happens
Trigger: Passing a path to a prefab that has been moved, renamed, or deleted. Typo in the path. Asset not yet imported or the path is relative in an unexpected way. Prefab exists in a package but the path is malformed.
Common situations: Hardcoded asset paths that go stale after refactoring. Paths constructed at runtime that don't match the actual asset location. Assets in Addressables or packages where the path convention differs.
Related errors
- Prefab Mode: GameObject must be part of a Prefab instance, o
- Prefab Mode: The 'openedFromInstance' GameObject '{go.name}'
- Cannot save as new prefab using the same path
- GameObject must be part of a Prefab instance, or null.
- Incorrect file extension: {prefabAssetPath}. Must be '.prefa
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/ebf9e61b1b72be26.
Report an issue: GitHub.