{"record":{"id":"682a8f17cdda96b9","repo":"CoplayDev/unity-mcp","slug":"max-width-should-be-larger-than-0","errorCode":null,"errorMessage":"Max width should be larger than 0","messagePattern":"Max width should be larger than 0","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/TextureTypePreviewGenerator.cs","lineNumber":29,"sourceCode":"namespace AssetStoreTools.Previews.Generators.Custom.TypeGenerators\r\n{\r\n    internal class TextureTypePreviewGenerator : TypePreviewGeneratorBase\r\n    {\r\n        private TextureTypeGeneratorSettings _settings;\r\n\r\n        public override event Action<int, int> OnAssetProcessed;\r\n\r\n        public TextureTypePreviewGenerator(TextureTypeGeneratorSettings settings) : base(settings)\r\n        {\r\n            _settings = settings;\r\n        }\r\n\r\n        public override void ValidateSettings()\r\n        {\r\n            base.ValidateSettings();\r\n\r\n            if (_settings.MaxWidth <= 0)\r\n                throw new ArgumentException(\"Max width should be larger than 0\");\r\n\r\n            if (_settings.MaxHeight <= 0)\r\n                throw new ArgumentException(\"Max height should be larger than 0\");\r\n        }\r\n\r\n        protected override IEnumerable<UnityEngine.Object> CollectAssets()\r\n        {\r\n            var textures = new List<UnityEngine.Object>();\r\n            var textureGuids = AssetDatabase.FindAssets(\"t:texture\", Settings.InputPaths);\r\n\r\n            foreach (var guid in textureGuids)\r\n            {\r\n                var texture = AssetDatabase.LoadAssetAtPath<Texture>(AssetDatabase.GUIDToAssetPath(guid));\r\n\r\n                // Skip nested textures\r\n                if (!AssetDatabase.IsMainAsset(texture))\r\n                    continue;\r\n\r","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/TypeGenerators/TextureTypePreviewGenerator.cs#L11-L47","documentation":"Thrown by TextureTypePreviewGenerator.ValidateSettings when _settings.MaxWidth is zero or negative. MaxWidth caps the output size of texture previews — source textures larger than MaxWidth are downscaled. Validation runs after the base class check of InputPaths and OutputPath.","triggerScenarios":"Calling Generate() or ValidateSettings() on a TextureTypePreviewGenerator with _settings.MaxWidth <= 0. MaxWidth is used during texture resize operations in the generation pipeline.","commonSituations":"Texture preview settings constructed without MaxWidth; settings deserialized from config with a missing field; UI control set to 0 or left at default.","solutions":["Set _settings.MaxWidth to a positive integer (e.g., 512 or 1024) before calling Generate.","Initialize MaxWidth and MaxHeight together when constructing TextureTypeGeneratorSettings.","Apply sensible defaults after deserialization."],"exampleFix":"// before\nvar settings = new TextureTypeGeneratorSettings { MaxWidth = 0, MaxHeight = 512, InputPaths = paths, OutputPath = outPath };\n\n// after\nvar settings = new TextureTypeGeneratorSettings { MaxWidth = 1024, MaxHeight = 1024, InputPaths = paths, OutputPath = outPath };","handlingStrategy":"validation","validationCode":"if (settings.MaxWidth <= 0)\n    settings.MaxWidth = 1024; // sensible default\n// or validate:\nif (settings.MaxWidth <= 0)\n    throw new InvalidOperationException(\"Texture preview MaxWidth must be a positive value.\");","typeGuard":"static bool IsValidTexturePreviewDimensions(TextureTypeGeneratorSettings s)\n    => s.MaxWidth > 0 && s.MaxHeight > 0;","tryCatchPattern":"try\n{\n    await generator.Generate();\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Max width should be larger than 0\"))\n{\n    settings.MaxWidth = 1024;\n    await generator.Generate();\n}","preventionTips":["Set MaxWidth and MaxHeight together when constructing texture preview settings.","Clamp UI inputs to a minimum of 1 for max dimension fields.","Apply defaults after deserialization."],"tags":["unity","asset-store-tools","preview","validation","texture"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}