{"record":{"id":"46a09ab87473e7cb","repo":"CoplayDev/unity-mcp","slug":"width-should-be-larger-than-0-46a09a","errorCode":null,"errorMessage":"Width should be larger than 0","messagePattern":"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/CustomPreviewGenerator.cs","lineNumber":30,"sourceCode":"{\r\n    internal class CustomPreviewGenerator : PreviewGeneratorBase\r\n    {\r\n        private CustomPreviewGenerationSettings _customSettings;\r\n\r\n        public override event Action<float> OnProgressChanged;\r\n\r\n        public CustomPreviewGenerator(CustomPreviewGenerationSettings settings)\r\n            : base(settings)\r\n        {\r\n            _customSettings = settings;\r\n        }\r\n\r\n        protected override void Validate()\r\n        {\r\n            base.Validate();\r\n\r\n            if (_customSettings.Width <= 0)\r\n                throw new ArgumentException(\"Width should be larger than 0\");\r\n\r\n            if (_customSettings.Height <= 0)\r\n                throw new ArgumentException(\"Height should be larger than 0\");\r\n\r\n            if (_customSettings.Depth <= 0)\r\n                throw new ArgumentException(\"Depth should be larger than 0\");\r\n\r\n            if (_customSettings.NativeWidth <= 0)\r\n                throw new ArgumentException(\"Native width should be larger than 0\");\r\n\r\n            if (_customSettings.NativeHeight <= 0)\r\n                throw new ArgumentException(\"Native height should be larger than 0\");\r\n        }\r\n\r\n        protected override async Task<PreviewGenerationResult> GenerateImpl()\r\n        {\r\n            var result = new PreviewGenerationResult()\r\n            {\r","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/CustomPreviewGenerator.cs#L12-L48","documentation":"Thrown by CustomPreviewGenerator.Validate() (CustomPreviewGenerator.cs:30) when CustomPreviewGenerationSettings.Width <= 0. Width is the output render resolution: it is propagated into SceneScreenshotterSettings.Width (material/model/prefab screenshots) and TextureTypeGeneratorSettings.MaxWidth. A zero or negative value would produce an invalid RenderTexture. Validate() runs inside Generate() before GenerateImpl() and outside its try/catch, so the ArgumentException propagates uncaught to the caller (typically the Preview Generator window).","triggerScenarios":"Calling generator.Generate() on a CustomPreviewGenerator built from a CustomPreviewGenerationSettings whose Width field was never assigned (default int = 0), or was explicitly set to 0 or a negative number. Occurs when settings are constructed programmatically without setting Width, or when the Preview Generator window submits while the width field is empty.","commonSituations":"Default-initializing a settings object with `new CustomPreviewGenerationSettings()` and forgetting Width (all int fields default to 0); a UI/code path that clears dimensions before validation; migration from an older settings shape that lacked Width.","solutions":["Set CustomPreviewGenerationSettings.Width to a positive value (e.g. 128 or 256) before calling Generate().","When building settings programmatically, populate all five dimension fields together (Width, Height, Depth, NativeWidth, NativeHeight) right after construction.","In the Preview Generator window, confirm the Width field holds a positive number before clicking Generate."],"exampleFix":"// before\nvar settings = new CustomPreviewGenerationSettings {\n    InputPaths = paths, OutputPath = outPath,\n    Height = 128, Depth = 100, NativeWidth = 1024, NativeHeight = 1024\n};\nawait new CustomPreviewGenerator(settings).Generate(); // throws\n\n// after\nvar settings = new CustomPreviewGenerationSettings {\n    InputPaths = paths, OutputPath = outPath,\n    Width = 256, Height = 128, Depth = 100, NativeWidth = 1024, NativeHeight = 1024\n};\nawait new CustomPreviewGenerator(settings).Generate();","handlingStrategy":"validation","validationCode":"// C# - check before Generate()\nvar s = settings as CustomPreviewGenerationSettings;\nif (s != null && s.Width <= 0)\n    throw new InvalidOperationException(\"CustomPreviewGenerationSettings.Width must be > 0 before generating previews.\");","typeGuard":"static bool HasValidWidth(CustomPreviewGenerationSettings s) => s != null && s.Width > 0;","tryCatchPattern":"try { await generator.Generate(); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Width\")) { /* report invalid width, fix settings */ }","preventionTips":["Centralize CustomPreviewGenerationSettings construction in one factory that asserts all five dimensions are positive.","Add a UI clamp so the Preview Generator window cannot submit a non-positive width."],"tags":["unity","asset-store-tools","preview-generation","validation","argument-exception"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}