CoplayDev/unity-mcp · error · ArgumentException

Input path cannot be null

Error message

Input path cannot be null

What it means

Thrown by TypePreviewGeneratorBase.ValidateSettings when Settings.InputPaths is null or an empty array. This is the base-class validation for all type-based preview generators (texture, audio, scene). InputPaths must contain at least one AssetDatabase folder path.

Source

Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/TypePreviewGeneratorBase.cs:26

using UnityEditor;

namespace AssetStoreTools.Previews.Generators.Custom.TypeGenerators
{
    internal abstract class TypePreviewGeneratorBase : ITypePreviewGenerator
    {
        public TypeGeneratorSettings Settings { get; }

        public abstract event Action<int, int> OnAssetProcessed;

        public TypePreviewGeneratorBase(TypeGeneratorSettings settings)
        {
            Settings = settings;
        }

        public virtual void ValidateSettings()
        {
            if (Settings.InputPaths == null || Settings.InputPaths.Length == 0)
                throw new ArgumentException("Input path cannot be null");

            foreach (var path in Settings.InputPaths)
            {
                var inputPath = path.EndsWith("/") ? path.Remove(path.Length - 1) : path;
                if (!AssetDatabase.IsValidFolder(inputPath))
                    throw new ArgumentException($"Input path '{inputPath}' is not a valid ADB folder");
            }

            if (string.IsNullOrEmpty(Settings.OutputPath))
                throw new ArgumentException("Output path cannot be null");
        }

        public async Task<List<PreviewMetadata>> Generate()
        {
            var generatedPreviews = new List<PreviewMetadata>();
            ValidateSettings();

            var assets = CollectAssets();

View on GitHub (pinned to c21bf496bc)

Solutions

  1. Populate Settings.InputPaths with at least one valid AssetDatabase folder path before calling Generate.
  2. Check for null/empty at the call site and report a clear upstream error.
  3. If paths come from user input, validate selection before starting preview generation.

Example fix

// before
var settings = new TextureTypeGeneratorSettings { InputPaths = new string[0], OutputPath = outPath, MaxWidth = 1024, MaxHeight = 1024 };

// after
var settings = new TextureTypeGeneratorSettings { InputPaths = new[] { "Assets/MyTextures" }, OutputPath = outPath, MaxWidth = 1024, MaxHeight = 1024 };
Defensive patterns

Strategy: validation

Validate before calling

if (settings.InputPaths == null || settings.InputPaths.Length == 0)
    throw new InvalidOperationException("InputPaths must contain at least one AssetDatabase folder.");

Type guard

static bool HasValidInputPaths(TypeGeneratorSettings s)
    => s?.InputPaths != null && s.InputPaths.Length > 0;

Try / catch

try
{
    await generator.Generate();
}
catch (ArgumentException ex) when (ex.Message.Contains("Input path cannot be null"))
{
    Debug.LogError("No input paths provided for preview generation.");
}

Prevention

When it happens

Trigger: Calling Generate() on any TypePreviewGeneratorBase subclass with Settings.InputPaths being null or having Length == 0. ValidateSettings is called at the top of Generate().

Common situations: Settings constructed without InputPaths; UI didn't bind the input folder selection; deserialized settings with a null InputPaths field; programmatic caller passed an empty array.

Related errors


AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13). Data as JSON: /api/errors/6ad3c63159313921. Report an issue: GitHub.