CoplayDev/unity-mcp · error · ArgumentException
Max height should be larger than 0
Error message
Max height should be larger than 0
What it means
Thrown by TextureTypePreviewGenerator.ValidateSettings when _settings.MaxHeight is zero or negative. MaxHeight caps the vertical dimension of texture previews. Validated immediately after MaxWidth in the same override.
Source
Thrown at TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/TextureTypePreviewGenerator.cs:32
{
private TextureTypeGeneratorSettings _settings;
public override event Action<int, int> OnAssetProcessed;
public TextureTypePreviewGenerator(TextureTypeGeneratorSettings settings) : base(settings)
{
_settings = settings;
}
public override void ValidateSettings()
{
base.ValidateSettings();
if (_settings.MaxWidth <= 0)
throw new ArgumentException("Max width should be larger than 0");
if (_settings.MaxHeight <= 0)
throw new ArgumentException("Max height should be larger than 0");
}
protected override IEnumerable<UnityEngine.Object> CollectAssets()
{
var textures = new List<UnityEngine.Object>();
var textureGuids = AssetDatabase.FindAssets("t:texture", Settings.InputPaths);
foreach (var guid in textureGuids)
{
var texture = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(guid));
// Skip nested textures
if (!AssetDatabase.IsMainAsset(texture))
continue;
textures.Add(texture);
}
View on GitHub (pinned to c21bf496bc)
Solutions
- Set _settings.MaxHeight to a positive integer (e.g., 512 or 1024) before calling Generate.
- Set MaxWidth and MaxHeight together in a settings factory.
- Default unset dimension fields after deserialization.
Example fix
// before
var settings = new TextureTypeGeneratorSettings { MaxWidth = 1024, MaxHeight = 0, InputPaths = paths, OutputPath = outPath };
// after
var settings = new TextureTypeGeneratorSettings { MaxWidth = 1024, MaxHeight = 1024, InputPaths = paths, OutputPath = outPath }; Defensive patterns
Strategy: validation
Validate before calling
if (settings.MaxHeight <= 0)
settings.MaxHeight = 1024; // sensible default
// or validate:
if (settings.MaxHeight <= 0)
throw new InvalidOperationException("Texture preview MaxHeight must be a positive value."); Type guard
static bool IsValidTexturePreviewDimensions(TextureTypeGeneratorSettings s)
=> s.MaxWidth > 0 && s.MaxHeight > 0; Try / catch
try
{
await generator.Generate();
}
catch (ArgumentException ex) when (ex.Message.Contains("Max height should be larger than 0"))
{
settings.MaxHeight = 1024;
await generator.Generate();
} Prevention
- Initialize MaxWidth and MaxHeight in a single settings construction step.
- Validate both max dimension fields before starting generation.
- Apply default values after deserialization for unset fields.
When it happens
Trigger: Calling Generate() or ValidateSettings() on a TextureTypePreviewGenerator with _settings.MaxHeight <= 0. MaxHeight feeds the resize logic during preview generation.
Common situations: Settings constructed with MaxWidth set but MaxHeight left at 0; deserialized config missing this field; partial settings clone.
Related errors
- Max width should be larger than 0
- 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/b47a5bc89248072d.
Report an issue: GitHub.