Unity-Technologies/UnityCsReference · critical · InvalidImportException

Failed to find {path} in {location}.

Error message

Failed to find {path} in {location}.

What it means

RenderPipelineResourcesEditorUtils.Load throws InvalidImportException when a ProjectPath asset cannot be resolved to a GUID, meaning the asset does not exist at the given project path. This occurs during render pipeline resource loading when a required shader or asset is missing from the project.

Source

Thrown at Editor/Mono/RenderPipelineResourcesEditorUtils.cs:180

            bool SetAndLoadIfNull(Array array, int index, string path, SearchType location)
            {
                var element = array.GetValue(index);
                if (IsNull(element))
                {
                    array.SetValue(Load(path, array.GetType().GetElementType(), location), index);
                    return true;
                }

                return false;
            }

            UnityEngine.Object Load(string path, Type type, SearchType location)
            {
                // Check if asset exist.
                // Direct loading can be prevented by AssetDatabase being reloading.
                var guid = AssetDatabase.AssetPathToGUID(path);
                if (location == SearchType.ProjectPath && String.IsNullOrEmpty(guid))
                    throw new InvalidImportException($"Failed to find {path} in {location}.");

                UnityEngine.Object result = type == typeof(Shader)
                    ? LoadShader(path, location)
                    : LoadNonShaderAssets(path, type, location);
                
                if (IsNull(result))
                    switch (location)
                    {
                        case SearchType.ProjectPath:
                            CheckTypeMismatch(path, type);
                            throw new InvalidImportException($"Cannot load. Path {path} is correct but AssetDatabase cannot load now.");
                        case SearchType.ShaderName: throw new InvalidImportException($"Failed to find {path} in {location}.");
                        case SearchType.BuiltinPath: throw new InvalidImportException($"Failed to find {path} in {location}.");
                        case SearchType.BuiltinExtraPath: throw new InvalidImportException($"Failed to find {path} in {location}.");
                    }
                    
                return result;
            }

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Verify the asset exists at the given path using AssetDatabase.LoadAssetAtPath or AssetDatabase.AssetPathToGUID.
  2. Ensure the correct render pipeline package (URP/HDRP) is installed via Package Manager.
  3. If upgrading, re-import render pipeline resources or reset them via Edit > Project Settings > Graphics.
  4. Check that the path uses forward slashes and is relative to the project (e.g., 'Packages/com.unity.render-pipelines.universal/...').

Example fix

// before
var shader = resource.Load("Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader", typeof(Shader), SearchType.ProjectPath);
// after
var guid = AssetDatabase.AssetPathToGUID(path);
if (!string.IsNullOrEmpty(guid))
    var shader = resource.Load(path, typeof(Shader), SearchType.ProjectPath);
else
    Debug.LogError($"Render pipeline asset missing at: {path}. Reinstall the package.");
Defensive patterns

Strategy: validation

Validate before calling

var guid = AssetDatabase.AssetPathToGUID(path);
if (!string.IsNullOrEmpty(guid))
    var asset = resource.Load(path, type, SearchType.ProjectPath);
else
    Debug.LogError($"Asset not found at project path: {path}");

Type guard

static bool ProjectAssetExists(string path) => !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(path));

Try / catch

try
{
    var asset = resource.Load(path, type, SearchType.ProjectPath);
}
catch (InvalidImportException ex)
{
    Debug.LogError($"Render pipeline asset missing: {path}. Reinstall URP/HDRP package.");
}

Prevention

When it happens

Trigger: Loading a render pipeline resource at a ProjectPath where AssetDatabase.AssetPathToGUID(path) returns an empty string, indicating no asset exists at that path.

Common situations: Render pipeline resources (SRP, URP, HDRP) reference shader/material paths that don't exist because the package isn't installed, the asset was deleted, or a version upgrade changed asset locations. Common after upgrading Unity or switching render pipelines.

Related errors


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