{"record":{"id":"5ac8c746e49c065d","repo":"CoplayDev/unity-mcp","slug":"depth-should-be-larger-than-0-5ac8c7","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/CustomPreviewGenerator.cs","lineNumber":36,"sourceCode":"\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\n            OnProgressChanged?.Invoke(0f);\r\n\r\n            var generatedPreviews = new List<PreviewMetadata>();\r","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/CustomPreviewGenerator.cs#L18-L54","documentation":"Thrown by CustomPreviewGenerator.Validate() (CustomPreviewGenerator.cs:36) when CustomPreviewGenerationSettings.Depth <= 0. Depth is the render depth used by SceneScreenshotterSettings.Depth for material/model/prefab screenshots (camera depth/orthographic sizing). Zero or negative depth would make the screenshot scene setup invalid. Thrown before GenerateImpl(), outside its try/catch, so it propagates as an uncaught ArgumentException.","triggerScenarios":"Generate() is called on settings where Depth was left at its default 0 or set negative. Happens when constructing CustomPreviewGenerationSettings without Depth, or when only texture/audio previews are intended but the shared Depth field is still required.","commonSituations":"Settings initializer that sets Width/Height but forgets Depth; assumption that Depth only matters for 3D screenshots and can be skipped (it cannot — Validate() always checks it).","solutions":["Set CustomPreviewGenerationSettings.Depth to a positive value (e.g. 100) before Generate().","Always populate Width, Height, Depth, NativeWidth, NativeHeight together when building custom settings.","Confirm the Depth field in the Preview Generator window before generating."],"exampleFix":"// before\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128 /* Depth missing */ };\nawait new CustomPreviewGenerator(settings).Generate(); // throws\n\n// after\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128, Depth = 100 };\nawait new CustomPreviewGenerator(settings).Generate();","handlingStrategy":"validation","validationCode":"var s = settings as CustomPreviewGenerationSettings;\nif (s != null && s.Depth <= 0)\n    throw new InvalidOperationException(\"CustomPreviewGenerationSettings.Depth must be > 0 before generating previews.\");","typeGuard":"static bool HasValidDepth(CustomPreviewGenerationSettings s) => s != null && s.Depth > 0;","tryCatchPattern":"try { await generator.Generate(); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Depth\")) { /* report invalid depth */ }","preventionTips":["Remember Depth is required even if you only generate texture/audio previews.","Set Depth (e.g. 100) whenever you build custom settings."],"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"}