{"record":{"id":"cd0b4f1137dea6ff","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-material-folder-path-0","errorCode":null,"errorMessage":"Invalid material folder path: {0}.","messagePattern":"Invalid material folder path: (.+?)\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs","lineNumber":1115,"sourceCode":"                {\n                    material.SetFloat(MaterialProperties.WindRippleKwToggle, 1.0f);\n                    if (windCfg.doShimmer != 0)\n                    {\n                        material.SetFloat(MaterialProperties.WindShimmerKwToggle, 1.0f);\n                    }\n                }\n            }\n        }\n\n        internal bool SearchAndRemapMaterials(string materialFolderPath)\n        {\n            bool changedMappings = false;\n\n            if (materialFolderPath == null)\n                throw new ArgumentNullException(\"materialFolderPath\");\n\n            if (string.IsNullOrEmpty(materialFolderPath))\n                throw new ArgumentException(string.Format(\"Invalid material folder path: {0}.\", materialFolderPath), \"materialFolderPath\");\n\n            string[] guids = AssetDatabase.FindAssets(\"t:Material\", new string[] { materialFolderPath });\n            List<Tuple<string, Material>> materials = new List<Tuple<string, Material>>();\n            foreach (string guid in guids)\n            {\n                string path = AssetDatabase.GUIDToAssetPath(guid);\n                // ensure that we only load material assets, not embedded materials\n                Material material = AssetDatabase.LoadMainAssetAtPath(path) as Material;\n                if (material)\n                    materials.Add(new Tuple<string, Material>(path, material));\n            }\n\n            m_OutputImporterData = AssetDatabase.LoadAssetAtPath<SpeedTreeImporterOutputData>(assetPath);\n            AssetIdentifier[] importedMaterials = m_OutputImporterData.materialsIdentifiers.ToArray();\n\n            foreach (Tuple<string, Material> material in materials)\n            {\n                string materialName = material.Item2.name;","sourceCodeStart":1097,"sourceCodeEnd":1133,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetPipeline/SpeedTree/SpeedTree9Importer.cs#L1097-L1133","documentation":"SpeedTree9Importer.SearchAndRemapMaterials throws ArgumentException with message 'Invalid material folder path: {0}.' when materialFolderPath is empty (but not null — null is caught by error 37's ArgumentNullException). The empty-path guard runs after the null check and before AssetDatabase.FindAssets, because FindAssets with an empty search folder would return unpredictable results. The interpolated message includes the offending path for debugging.","triggerScenarios":"Calling SearchAndRemapMaterials(\"\") where the path is an empty string. This happens when a folder path field is set to empty by a UI reset, a serialization migration, or a user clearing the folder field in the inspector.","commonSituations":"SpeedTree importer inspector workflows where the user clears or never sets the external material folder path. Also occurs after reimporting SpeedTree assets from projects where the material folder setting was not preserved.","solutions":["Check string.IsNullOrEmpty(materialFolderPath) before calling to catch both null and empty.","Provide a default folder path (the asset's own directory or 'Assets/') when the field is empty.","Disable the remap button in the inspector UI when the folder path is empty."],"exampleFix":"// before\nimporter.SearchAndRemapMaterials(folderPath);\n\n// after\nif (!string.IsNullOrEmpty(folderPath))\n    importer.SearchAndRemapMaterials(folderPath);\nelse\n    Debug.LogWarning(\"SpeedTree material folder path is empty; set a valid folder before remapping\");","handlingStrategy":"validation","validationCode":"if (!string.IsNullOrEmpty(materialFolderPath))\n    importer.SearchAndRemapMaterials(materialFolderPath);\nelse\n    Debug.LogWarning(\"SpeedTree material folder path is empty; set a valid folder\");","typeGuard":"static bool IsValidFolderPath(string path) => !string.IsNullOrEmpty(path);","tryCatchPattern":"try { importer.SearchAndRemapMaterials(folderPath); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Invalid material folder path\"))\n{ Debug.LogWarning($\"Cannot remap: {ex.Message}\"); }","preventionTips":["Disable the remap UI action when the folder path is empty","Provide a default folder (asset directory) when the field is unset","Use string.IsNullOrEmpty to catch both null and empty before calling remap"],"tags":["unity","csharp","asset-pipeline","speedtree","material-remap","argument-validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}