{"record":{"id":"f582478bd3c0dc5d","repo":"CoplayDev/unity-mcp","slug":"native-height-should-be-larger-than-0-f58247","errorCode":null,"errorMessage":"Native height should be larger than 0","messagePattern":"Native 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":42,"sourceCode":"\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\n            OnProgressChanged?.Invoke(0f);\r\n\r\n            var generatedPreviews = new List<PreviewMetadata>();\r\n            var existingPreviews = GetExistingPreviews();\r\n            var generators = CreateGenerators(existingPreviews);\r\n\r\n            var currentGenerator = 0;\r\n            Action<int, int> generatorProgressCallback = null;\r\n            generatorProgressCallback = (currentAsset, totalAssets) => ReportProgress(currentGenerator, generators.Count(), currentAsset, totalAssets);\r","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/CustomPreviewGenerator.cs#L24-L60","documentation":"Thrown by CustomPreviewGenerator.Validate() (CustomPreviewGenerator.cs:42) when CustomPreviewGenerationSettings.NativeHeight <= 0. NativeHeight is the native offscreen render height (pre-downscale) passed to SceneScreenshotterSettings.NativeHeight. Non-positive makes the render target invalid. It is the last of the five dimension checks; thrown before GenerateImpl() and outside its try/catch, so it propagates as an uncaught ArgumentException.","triggerScenarios":"Generate() called with NativeHeight unset (default 0) or <= 0. Occurs when the native-resolution pair is partially set (NativeWidth set, NativeHeight forgotten) or both omitted.","commonSituations":"Initializer that sets NativeWidth but not NativeHeight; copy-paste error leaving one native field at default; settings deserialization that dropped NativeHeight.","solutions":["Set CustomPreviewGenerationSettings.NativeHeight to a positive value (e.g. 1024) before Generate().","Always set NativeWidth and NativeHeight as a pair alongside Width/Height/Depth.","Verify the Native Height field in the Preview Generator window before generating."],"exampleFix":"// before\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128, Depth = 100, NativeWidth = 1024 /* NativeHeight missing */ };\nawait new CustomPreviewGenerator(settings).Generate(); // throws\n\n// after\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128, Depth = 100, NativeWidth = 1024, NativeHeight = 1024 };\nawait new CustomPreviewGenerator(settings).Generate();","handlingStrategy":"validation","validationCode":"var s = settings as CustomPreviewGenerationSettings;\nif (s != null && s.NativeHeight <= 0)\n    throw new InvalidOperationException(\"CustomPreviewGenerationSettings.NativeHeight must be > 0 before generating previews.\");","typeGuard":"static bool HasValidNativeHeight(CustomPreviewGenerationSettings s) => s != null && s.NativeHeight > 0;","tryCatchPattern":"try { await generator.Generate(); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Native height\")) { /* report invalid native height */ }","preventionTips":["Set NativeWidth and NativeHeight together to avoid the partial-pair mistake.","Add a single assertion covering all five dimension fields before Generate()."],"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"}