Unity-Technologies/UnityCsReference · error · InvalidImportException

Host type is not matching any asset type at Path {path}.

Error message

Host type is not matching any asset type at Path {path}.

What it means

RenderPipelineResourcesEditorUtils.CheckTypeMismatch throws InvalidImportException when the host type expected by a render pipeline resource does not match any asset type found at the given path. This is a type-compatibility check that loads all assets at a path and verifies at least one is assignable to the expected type.

Source

Thrown at Editor/Mono/RenderPipelineResourcesEditorUtils.cs:238

                    SearchType.ProjectPath => AssetDatabase.LoadAssetAtPath(path, type), //return null if path is wrong
                    SearchType.ShaderName => throw new ArgumentException($"{nameof(SearchType.ShaderName)} is only available for Shaders."),
                    _ => throw new NotImplementedException($"Unknown {location}")
                };

            void CheckTypeMismatch(string path, Type expectedType)
            {
                UnityEngine.Object[] assets = AssetDatabase.LoadAllAssetsAtPath(path);
                if (assets == null)
                    return;
                bool foundCandidate = false;
                foreach (var asset in assets)
                    if (expectedType.IsAssignableFrom(asset.GetType()))
                    {
                        foundCandidate = true;
                        break;
                    }
                if (!foundCandidate)
                    throw new InvalidImportException($"Host type is not matching any asset type at Path {path}.");
            }
        }
    }
}

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Verify the asset at the path is of the expected type using AssetDatabase.LoadAssetAtPath(path, expectedType).
  2. Check the asset's import settings (e.g., texture import type, model import settings) to ensure the output type matches.
  3. If the asset was replaced, re-assign the correct asset in the render pipeline resource inspector (Project Settings > Graphics or the URP/HDRP asset).
  4. Re-import the asset to ensure its type matches expectations.
  5. Check for type hierarchies: a base type reference may need a derived type asset (e.g., expecting Texture but only a Material is present).

Example fix

// before
// path points to a Material but expectedType is Texture
var asset = resource.Load("Assets/Materials/MyMaterial.mat", typeof(Texture), SearchType.ProjectPath);
// after
var found = AssetDatabase.LoadAssetAtPath<Texture>("Assets/Materials/MyMaterial.mat");
if (found != null)
    var asset = resource.Load("Assets/Materials/MyMaterial.mat", typeof(Texture), SearchType.ProjectPath);
else
{
    var texPath = "Assets/Textures/MyTexture.asset";
    var asset = resource.Load(texPath, typeof(Texture), SearchType.ProjectPath);
}
Defensive patterns

Strategy: validation

Validate before calling

var testAsset = AssetDatabase.LoadAssetAtPath(path, expectedType);
if (testAsset != null)
    var asset = resource.Load(path, expectedType, SearchType.ProjectPath);
else
    Debug.LogError($"Asset at {path} is not of expected type {expectedType.Name}");

Type guard

static bool AssetMatchesType(string path, Type expected)
    => AssetDatabase.LoadAssetAtPath(path, expected) != null;

Try / catch

try
{
    var asset = resource.Load(path, type, SearchType.ProjectPath);
}
catch (InvalidImportException ex) when (ex.Message.Contains("Host type"))
{
    Debug.LogError($"Type mismatch at {path}. Expected {type.Name}. Check asset import settings.");
}

Prevention

When it happens

Trigger: Loading assets at a path where AssetDatabase.LoadAllAssetsAtPath returns assets, but none of them are assignable to the expected type (expectedType.IsAssignableFrom(asset.GetType()) fails for all assets at that path).

Common situations: A render pipeline resource slot expects a specific type (e.g., a ComputeShader or Texture2DArray) but the asset at that path is a different type (e.g., a regular Texture2D or Material). Common when assets are replaced with incompatible types, or when a path was reassigned to point at a different asset type after a pipeline upgrade. Also occurs with importer settings that change the output type.

Related errors


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