{"record":{"id":"8075e682728d7693","repo":"CoplayDev/unity-mcp","slug":"native-height-should-be-larger-than-0","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/Custom/Screenshotters/SceneScreenshotterBase.cs","lineNumber":51,"sourceCode":"            return _camera;\r\n        }\r\n\r\n        public virtual void ValidateSettings()\r\n        {\r\n            if (Settings.Width <= 0)\r\n                throw new ArgumentException(\"Width should be larger than 0\");\r\n\r\n            if (Settings.Height <= 0)\r\n                throw new ArgumentException(\"Height should be larger than 0\");\r\n\r\n            if (Settings.Depth <= 0)\r\n                throw new ArgumentException(\"Depth should be larger than 0\");\r\n\r\n            if (Settings.NativeWidth <= 0)\r\n                throw new ArgumentException(\"Native width should be larger than 0\");\r\n\r\n            if (Settings.NativeHeight <= 0)\r\n                throw new ArgumentException(\"Native height should be larger than 0\");\r\n        }\r\n\r\n        public abstract void PositionCamera(GameObject target);\r\n\r\n        public string Screenshot(string outputPath)\r\n        {\r\n            ValidateSettings();\r\n\r\n            var texture = GraphicsUtility.GetTextureFromCamera(Camera, Settings.NativeWidth, Settings.NativeHeight, Settings.Depth);\r\n\r\n            if (Settings.Width < Settings.NativeWidth || Settings.Height < Settings.NativeHeight)\r\n                texture = GraphicsUtility.ResizeTexture(texture, Settings.Width, Settings.Height);\r\n\r\n            var extension = PreviewConvertUtility.ConvertExtension(Settings.Format);\r\n            var writtenPath = $\"{outputPath}.{extension}\";\r\n            var bytes = PreviewConvertUtility.ConvertTexture(texture, Settings.Format);\r\n            File.WriteAllBytes(writtenPath, bytes);\r\n\r","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/Custom/Screenshotters/SceneScreenshotterBase.cs#L33-L69","documentation":"Thrown by SceneScreenshotterBase.ValidateSettings when Settings.NativeHeight is zero or negative. NativeHeight is the vertical render resolution for GetTextureFromCamera, checked after NativeWidth. The screenshot pipeline renders at native dimensions then optionally resizes down to Width/Height.","triggerScenarios":"Calling Screenshot(outputPath) or ValidateSettings() with Settings.NativeHeight <= 0. NativeHeight feeds GraphicsUtility.GetTextureFromCamera.","commonSituations":"Settings partially initialized — Width, Height, NativeWidth set but NativeHeight left at default; config deserialization missing this field; settings cloned from another object where NativeHeight was cleared.","solutions":["Set Settings.NativeHeight to a positive integer before calling Screenshot.","Construct settings via a factory that guarantees all five dimension fields are populated.","After deserialization, default NativeHeight to Height if it is still zero."],"exampleFix":"// before\nvar settings = new SceneScreenshotterSettings { Width = 1024, Height = 1024, Depth = 24, NativeWidth = 2048, NativeHeight = 0 };\n\n// after\nvar settings = new SceneScreenshotterSettings { Width = 1024, Height = 1024, Depth = 24, NativeWidth = 2048, NativeHeight = 2048 };","handlingStrategy":"validation","validationCode":"if (settings.NativeHeight <= 0)\n    settings.NativeHeight = settings.Height > 0 ? settings.Height : 1080;\n// or validate:\nif (settings.NativeHeight <= 0)\n    throw new InvalidOperationException(\"NativeHeight must be set to a positive value.\");","typeGuard":"static bool IsValidScreenshotDimensions(SceneScreenshotterSettings s)\n    => s.Width > 0 && s.Height > 0 && s.Depth > 0 && s.NativeWidth > 0 && s.NativeHeight > 0;","tryCatchPattern":"try\n{\n    screenshotter.Screenshot(outputPath);\n}\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Native height should be larger than 0\"))\n{\n    settings.NativeHeight = settings.Height;\n    screenshotter.Screenshot(outputPath);\n}","preventionTips":["Set NativeHeight alongside NativeWidth in initialization.","Default NativeHeight to Height if not explicitly configured.","Validate all five dimension fields in a single pre-flight check."],"tags":["unity","asset-store-tools","preview","validation","render-texture"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}