CoplayDev/unity-mcp · error · ArgumentException
Output path cannot be null
Error message
Output path cannot be null
What it means
Thrown by PreviewGeneratorBase.Validate() (PreviewGeneratorBase.cs:40) when Settings.OutputPath is null or empty. OutputPath is where preview files are written (Directory.CreateDirectory and file writes use it). Null/empty would make file IO fail. Base check, runs for all generators before GenerateImpl(), outside its try/catch — an uncaught ArgumentException.
Source
Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/PreviewGeneratorBase.cs:40
{
Validate();
var result = await GenerateImpl();
if (result.Success)
{
CachingService.CacheMetadata(result.GeneratedPreviews);
}
return result;
}
protected virtual void Validate()
{
if (Settings.InputPaths == null || Settings.InputPaths.Length == 0)
throw new ArgumentException("Input paths cannot be null");
if (string.IsNullOrEmpty(Settings.OutputPath))
throw new ArgumentException("Output path cannot be null");
}
protected abstract Task<PreviewGenerationResult> GenerateImpl();
}
}View on GitHub (pinned to c21bf496bc)
Solutions
- Set Settings.OutputPath to a non-empty folder path before Generate().
- Disable Generate in the UI until an output path is selected.
- Assign OutputPath alongside InputPaths at construction.
Example fix
// before
var settings = new CustomPreviewGenerationSettings { InputPaths = paths /* OutputPath missing */ };
await new CustomPreviewGenerator(settings).Generate(); // throws
// after
var settings = new CustomPreviewGenerationSettings { InputPaths = paths, OutputPath = "Assets/Previews" };
await new CustomPreviewGenerator(settings).Generate(); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(settings.OutputPath))
throw new InvalidOperationException("PreviewGenerationSettings.OutputPath must be a non-empty path before generating."); Type guard
static bool HasOutputPath(PreviewGenerationSettings s) => s != null && !string.IsNullOrEmpty(s.OutputPath);
Try / catch
try { await generator.Generate(); }
catch (ArgumentException ex) when (ex.Message.Contains("Output path")) { /* report missing output path */ } Prevention
- Always assign OutputPath alongside InputPaths.
- Disable Generate in the UI until an output folder is chosen.
When it happens
Trigger: Calling Generate() with OutputPath unset (null) or set to an empty string. Occurs when settings are built without OutputPath, or when an output-folder picker returns empty.
Common situations: Settings initializer that sets InputPaths but not OutputPath; UI flow that allows Generate with no output folder chosen; a path that was cleared before submit.
Related errors
- Width should be larger than 0
- Height should be larger than 0
- Depth should be larger than 0
- Native width should be larger than 0
- Native height should be larger than 0
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/b74369d666a68156.
Report an issue: GitHub.