{"record":{"id":"248261d10f4e2ad7","repo":"CoplayDev/unity-mcp","slug":"height-should-be-larger-than-0-248261","errorCode":null,"errorMessage":"Height should be larger than 0","messagePattern":"Height 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":33,"sourceCode":"        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\n                GenerationType = _customSettings.GenerationType\r\n            };\r\n\r","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/CustomPreviewGenerator.cs#L15-L51","documentation":"Thrown by CustomPreviewGenerator.Validate() (CustomPreviewGenerator.cs:33) when CustomPreviewGenerationSettings.Height <= 0. Height is the vertical output render resolution, propagated into SceneScreenshotterSettings.Height and TextureTypeGeneratorSettings.MaxHeight. Zero/negative height yields an invalid RenderTexture. Like the other dimension checks it runs before GenerateImpl() and is not caught by its try/catch, so it surfaces as an uncaught ArgumentException.","triggerScenarios":"Calling Generate() with Height unset (default 0) or set <= 0 on a CustomPreviewGenerationSettings. Same lifecycle as the Width check: a settings object built without assigning Height, or a UI submit with an empty height field.","commonSituations":"Object-initializer that sets Width but omits Height; refactoring that renamed or removed the Height assignment; default-int-zero slipping through a code path that bypasses the window's own clamping.","solutions":["Set CustomPreviewGenerationSettings.Height to a positive value (e.g. 128) before Generate().","Populate all dimension fields (Width, Height, Depth, NativeWidth, NativeHeight) together at construction.","Verify the height field in the Preview Generator window is non-empty before generating."],"exampleFix":"// before\nvar settings = new CustomPreviewGenerationSettings { Width = 256, /* Height missing */ };\nawait new CustomPreviewGenerator(settings).Generate(); // throws\n\n// after\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128 };\nawait new CustomPreviewGenerator(settings).Generate();","handlingStrategy":"validation","validationCode":"var s = settings as CustomPreviewGenerationSettings;\nif (s != null && s.Height <= 0)\n    throw new InvalidOperationException(\"CustomPreviewGenerationSettings.Height must be > 0 before generating previews.\");","typeGuard":"static bool HasValidHeight(CustomPreviewGenerationSettings s) => s != null && s.Height > 0;","tryCatchPattern":"try { await generator.Generate(); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Height\")) { /* report invalid height */ }","preventionTips":["Validate Height together with Width in the same pre-flight check.","Never partial-initialize the dimension fields."],"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"}