CoplayDev/unity-mcp · error · ArgumentException
Output path cannot be null
Error message
Output path cannot be null
What it means
Thrown by TypePreviewGeneratorBase.ValidateSettings when Settings.OutputPath is null or an empty string. OutputPath is where generated preview images are written. This base-class validation runs after the InputPaths loop.
Source
Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/TypePreviewGeneratorBase.cs:36
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();
assets = FilterIgnoredAssets(assets);
if (assets.Count() == 0)
return generatedPreviews;
return await GenerateImpl(assets);
}
protected abstract IEnumerable<UnityEngine.Object> CollectAssets();
View on GitHub (pinned to c21bf496bc)
Solutions
- Set Settings.OutputPath to a valid writable directory path before calling Generate.
- Default OutputPath to a known preview output directory if the user didn't specify one.
- Check for null/empty at the call site and prompt for or assign a default output location.
Example fix
// before
var settings = new TextureTypeGeneratorSettings { InputPaths = paths, OutputPath = null, MaxWidth = 1024, MaxHeight = 1024 };
// after
var settings = new TextureTypeGeneratorSettings { InputPaths = paths, OutputPath = "Assets/PreviewOutput", MaxWidth = 1024, MaxHeight = 1024 }; Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(settings.OutputPath))
settings.OutputPath = "Assets/PreviewOutput"; // default
// or validate:
if (string.IsNullOrEmpty(settings.OutputPath))
throw new InvalidOperationException("OutputPath must be set to a valid directory."); Type guard
static bool HasValidOutputPath(TypeGeneratorSettings s)
=> !string.IsNullOrEmpty(s?.OutputPath); Try / catch
try
{
await generator.Generate();
}
catch (ArgumentException ex) when (ex.Message.Contains("Output path cannot be null"))
{
settings.OutputPath = "Assets/PreviewOutput";
await generator.Generate();
} Prevention
- Set OutputPath to a known writable directory before calling Generate.
- Default OutputPath when the user doesn't specify one.
- Check for null/empty after deserialization and apply a default.
When it happens
Trigger: Calling Generate() with Settings.OutputPath being null or string.Empty. ValidateSettings checks string.IsNullOrEmpty(Settings.OutputPath).
Common situations: Settings constructed without setting OutputPath; UI dialog for output folder was cancelled; deserialized config missing the output path field; OutputPath set to a whitespace-only string.
Related errors
- Input path '{inputPath}' is not a valid ADB folder
- 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
AI-assisted analysis of CoplayDev/unity-mcp@c21bf496bc (2026-08-13).
Data as JSON: /api/errors/5839712966b4684c.
Report an issue: GitHub.