{"record":{"id":"97980467944ef732","repo":"Unity-Technologies/UnityCsReference","slug":"could-not-find-materialproperty-propertyname","errorCode":null,"errorMessage":"Could not find MaterialProperty: '{propertyName}', Num properties: {properties.Length}","messagePattern":"Could not find MaterialProperty: '(.+?)', Num properties: (.+?)","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/ShaderGUI.cs","lineNumber":60,"sourceCode":"        virtual public void ValidateMaterial(Material material)\n        {\n        }\n\n        // Utility methods\n        protected static MaterialProperty FindProperty(string propertyName, MaterialProperty[] properties)\n        {\n            return FindProperty(propertyName, properties, true);\n        }\n\n        protected static MaterialProperty FindProperty(string propertyName, MaterialProperty[] properties, bool propertyIsMandatory)\n        {\n            for (var i = 0; i < properties.Length; i++)\n                if (properties[i] != null && properties[i].name == propertyName)\n                    return properties[i];\n\n            // We assume all required properties can be found, otherwise something is broken\n            if (propertyIsMandatory)\n                throw new ArgumentException(\"Could not find MaterialProperty: '\" + propertyName + \"', Num properties: \" + properties.Length);\n            return null;\n        }\n    }\n\n    internal static class ShaderGUIUtility\n    {\n        private static Type ExtractCustomEditorType(string customEditorName)\n        {\n            if (string.IsNullOrEmpty(customEditorName))\n                return null;\n\n            // To allow users to implement their own ShaderGUI for the Standard shader we iterate in reverse order\n            // because the UnityEditor assembly is assumed first in the assembly list.\n            // Users can now place a copy of the StandardShaderGUI script in the project and start modifying that copy to make their own version.\n            var unityEditorFullName = $\"UnityEditor.{customEditorName}\"; // for convenience: adding UnityEditor namespace is not needed in the shader\n            foreach (var type in TypeCache.GetTypesDerivedFrom<ShaderGUI>())\n            {\n                if (type.FullName.Equals(customEditorName, StringComparison.Ordinal) ||","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/ShaderGUI.cs#L42-L78","documentation":"Thrown by ShaderGUI.FindProperty when propertyIsMandatory is true and no MaterialProperty with the given name exists in the provided properties array. The base ShaderGUI assumes required shader properties are always present.","triggerScenarios":"A custom ShaderGUI calls FindProperty(\"_SomeName\", props, true) but the material's shader does not declare that property. Shader changed/renamed a property while the ShaderGUI still references the old name.","commonSituations":"Shader renamed or removed a property after the ShaderGUI was written. ShaderGUI applied to a material whose shader lacks the expected properties. Typo in the property name string.","solutions":["Call FindProperty with propertyIsMandatory=false and null-check the result before use.","Verify the shader declares the property name referenced by the ShaderGUI (case-sensitive).","Update the ShaderGUI to match the current shader's property names."],"exampleFix":"// before\nvar prop = FindProperty(\"_BaseColor\", props, true);\n\n// after\nvar prop = FindProperty(\"_BaseColor\", props, false);\nif (prop == null)\n{\n    Debug.LogWarning($\"Shader {material.shader.name} missing property _BaseColor\");\n    return;\n}","handlingStrategy":"validation","validationCode":"var prop = FindProperty(name, props, false);\nbool ok = prop != null;","typeGuard":null,"tryCatchPattern":"try { FindProperty(name, props, true); }\ncatch (ArgumentException) { /* missing property, skip */ }","preventionTips":["Use propertyIsMandatory=false and null-check.","Keep shader and ShaderGUI property names in sync."],"tags":["unity","editor","shadergui","material-property","missing-property"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}