{"record":{"id":"ed41d7ed79cbce65","repo":"CoplayDev/unity-mcp","slug":"height-should-be-larger-than-0","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/Custom/Screenshotters/SceneScreenshotterBase.cs","lineNumber":42,"sourceCode":"            if (_camera == null)\r\n            {\r\n#if UNITY_2022_3_OR_NEWER\r\n                _camera = GameObject.FindFirstObjectByType<Camera>(FindObjectsInactive.Include);\r\n#else\r\n                _camera = GameObject.FindObjectOfType<Camera>();\r\n#endif\r\n            }\r\n\r\n            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","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/Custom/Screenshotters/SceneScreenshotterBase.cs#L24-L60","documentation":"Thrown by SceneScreenshotterBase.ValidateSettings when Settings.Height is zero or negative. Height dimensions the output screenshot texture vertically. Validation fires synchronously before camera rendering in Screenshot().","triggerScenarios":"Calling Screenshot(outputPath) or ValidateSettings() on a SceneScreenshotterBase subclass with Settings.Height <= 0.","commonSituations":"Settings deserialized with missing height; UI control left at default 0; programmatic caller forgot to set Height after constructing settings.","solutions":["Set Settings.Height to a positive integer (e.g., 1080) before calling Screenshot.","Apply default dimensions after deserializing settings from disk.","Clamp height at the UI layer to a minimum of 1."],"exampleFix":"// before\nvar settings = new SceneScreenshotterSettings { Width = 1920, Height = 0, ... };\nscreenshotter.Screenshot(outputPath);\n\n// after\nvar settings = new SceneScreenshotterSettings { Width = 1920, Height = 1080, ... };\nscreenshotter.Screenshot(outputPath);","handlingStrategy":"validation","validationCode":"if (settings.Height <= 0)\n    settings.Height = 1080; // apply default\n// or validate before calling Screenshot:\nif (settings.Height <= 0)\n    throw new InvalidOperationException(\"Screenshot Height 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(\"Height should be larger than 0\"))\n{\n    settings.Height = 1080;\n    screenshotter.Screenshot(outputPath);\n}","preventionTips":["Set Height alongside Width in the same initialization block.","Use a settings factory that guarantees all dimensions are positive.","Validate dimension fields after any deserialization or reset operation."],"tags":["unity","asset-store-tools","preview","validation","screenshot"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}