{"record":{"id":"086472855e610f66","repo":"CoplayDev/unity-mcp","slug":"native-width-should-be-larger-than-0-086472","errorCode":null,"errorMessage":"Native width should be larger than 0","messagePattern":"Native width 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":39,"sourceCode":"        {\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\n            var existingPreviews = GetExistingPreviews();\r\n            var generators = CreateGenerators(existingPreviews);\r\n\r","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/TestProjects/AssetStoreUploads/Packages/com.unity.asset-store-tools/Editor/Previews/Scripts/Generators/CustomPreviewGenerator.cs#L21-L57","documentation":"Thrown by CustomPreviewGenerator.Validate() (CustomPreviewGenerator.cs:39) when CustomPreviewGenerationSettings.NativeWidth <= 0. NativeWidth is the native render resolution (before downscale) passed to SceneScreenshotterSettings.NativeWidth for material/model/prefab screenshots. A non-positive native width makes the offscreen render undefined. Runs before GenerateImpl(), outside its try/catch — an uncaught ArgumentException.","triggerScenarios":"Generate() called with NativeWidth unset (default 0) or <= 0. Arises when settings are built without the native-resolution fields, or when only audio/texture previews are wanted but the required NativeWidth is left at default.","commonSituations":"Initializer that sets Width/Height but omits NativeWidth; confusion between Width (output) and NativeWidth (offscreen render size) leading to the native fields being skipped.","solutions":["Set CustomPreviewGenerationSettings.NativeWidth to a positive value (e.g. 1024) before Generate().","Set NativeWidth/NativeHeight together with Width/Height/Depth at construction time.","Check the Native Width field in the Preview Generator window before generating."],"exampleFix":"// before\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128, Depth = 100 /* NativeWidth missing */ };\nawait new CustomPreviewGenerator(settings).Generate(); // throws\n\n// after\nvar settings = new CustomPreviewGenerationSettings { Width = 256, Height = 128, Depth = 100, NativeWidth = 1024 };\nawait new CustomPreviewGenerator(settings).Generate();","handlingStrategy":"validation","validationCode":"var s = settings as CustomPreviewGenerationSettings;\nif (s != null && s.NativeWidth <= 0)\n    throw new InvalidOperationException(\"CustomPreviewGenerationSettings.NativeWidth must be > 0 before generating previews.\");","typeGuard":"static bool HasValidNativeWidth(CustomPreviewGenerationSettings s) => s != null && s.NativeWidth > 0;","tryCatchPattern":"try { await generator.Generate(); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Native width\")) { /* report invalid native width */ }","preventionTips":["Treat NativeWidth/NativeHeight as a pair and set them together (e.g. 1024x1024).","Do not confuse NativeWidth (offscreen render size) with Width (output size)."],"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"}