{"record":{"id":"f8abefd46f3332e3","repo":"CoplayDev/unity-mcp","slug":"depth-should-be-larger-than-0","errorCode":null,"errorMessage":"Depth should be larger than 0","messagePattern":"Depth 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":45,"sourceCode":"                _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\n\r\n            if (Settings.Width < Settings.NativeWidth || Settings.Height < Settings.NativeHeight)\r\n                texture = GraphicsUtility.ResizeTexture(texture, Settings.Width, Settings.Height);\r","sourceCodeStart":27,"sourceCodeEnd":63,"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#L27-L63","documentation":"Thrown by SceneScreenshotterBase.ValidateSettings when Settings.Depth is zero or negative. Depth controls the render texture depth buffer precision used when capturing the screenshot via GraphicsUtility.GetTextureFromCamera. Validation fires before texture creation.","triggerScenarios":"Calling Screenshot(outputPath) or ValidateSettings() with Settings.Depth <= 0. Depth is passed to GetTextureFromCamera alongside NativeWidth, NativeHeight.","commonSituations":"Settings object constructed without setting Depth (defaults to 0); config file missing depth field; depth field accidentally set to 0 by a UI reset.","solutions":["Set Settings.Depth to a standard depth buffer value (typically 16 or 24) before rendering.","Initialize all screenshot dimension fields (Width, Height, Depth, NativeWidth, NativeHeight) together in a factory method.","Apply post-deserialization defaults for any unset numeric fields."],"exampleFix":"// before\nvar settings = new SceneScreenshotterSettings { Width = 1920, Height = 1080, Depth = 0, NativeWidth = 1920, NativeHeight = 1080 };\n\n// after\nvar settings = new SceneScreenshotterSettings { Width = 1920, Height = 1080, Depth = 24, NativeWidth = 1920, NativeHeight = 1080 };","handlingStrategy":"validation","validationCode":"if (settings.Depth <= 0)\n    settings.Depth = 24; // standard depth buffer\n// or validate:\nif (settings.Depth <= 0)\n    throw new InvalidOperationException(\"Screenshot Depth must be a positive value (typically 16 or 24).\");","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(\"Depth should be larger than 0\"))\n{\n    settings.Depth = 24;\n    screenshotter.Screenshot(outputPath);\n}","preventionTips":["Set Depth to a standard value (16 or 24) alongside Width and Height.","Group all five dimension fields in a single initialization method.","Apply defaults after deserialization to cover missing fields."],"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"}