{"record":{"id":"bd2b2dce7f84684b","repo":"Unity-Technologies/UnityCsReference","slug":"the-serializedproperty-0-is-not-supported-by-b","errorCode":null,"errorMessage":"The SerializedProperty '{0}' is not supported by BeginProperty.","messagePattern":"The SerializedProperty '(.+?)' is not supported by BeginProperty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/MaterialEditor.cs","lineNumber":1356,"sourceCode":"            return count;\n        }\n\n        static bool AllTargetsAreVariants(Object[] targets)\n        {\n            return GetVariantCount(targets) == targets.Length;\n        }\n\n        static MaterialSerializedProperty GetMaterialSerializedProperty(SerializedProperty property)\n        {\n            if (property.propertyPath == \"m_LightmapFlags\")\n                return MaterialSerializedProperty.LightmapFlags;\n            if (property.propertyPath == \"m_EnableInstancingVariants\")\n                return MaterialSerializedProperty.EnableInstancingVariants;\n            if (property.propertyPath == \"m_DoubleSidedGI\")\n                return MaterialSerializedProperty.DoubleSidedGI;\n            if (property.propertyPath == \"m_CustomRenderQueue\")\n                return MaterialSerializedProperty.CustomRenderQueue;\n            throw new ArgumentException(string.Format(\"The SerializedProperty '{0}' is not supported by BeginProperty.\", property.propertyPath));\n        }\n\n        internal static void BeginProperty(MaterialSerializedProperty property, Object[] targets)\n        {\n            MaterialProperty.BeginProperty(property, targets);\n        }\n\n        internal static void BeginProperty(Rect rect, MaterialSerializedProperty property, Object[] targets)\n        {\n            MaterialProperty.BeginProperty(rect, null, property, targets);\n        }\n\n        public static void BeginProperty(SerializedProperty property)\n        {\n            MaterialProperty.BeginProperty(GetMaterialSerializedProperty(property), property.serializedObject.targetObjects);\n        }\n\n        public static void BeginProperty(Rect rect, SerializedProperty property)","sourceCodeStart":1338,"sourceCodeEnd":1374,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/MaterialEditor.cs#L1338-L1374","documentation":"Thrown by GetMaterialSerializedProperty when the SerializedProperty's propertyPath is not one of the four recognized material-level paths (m_LightmapFlags, m_EnableInstancingVariants, m_DoubleSidedGI, m_CustomRenderQueue). BeginProperty only handles these specific material serialization fields; any other property path is rejected.","triggerScenarios":"Calling BeginProperty indirectly via a custom MaterialEditor/ShaderGUI that iterates over SerializedObject properties and routes an unrecognized path through GetMaterialSerializedProperty. Passing a shader-specific float/vector property (e.g. a user shader uniform) instead of a material-level meta field.","commonSituations":"Writing a custom ShaderGUI that calls MaterialEditor.BeginProperty for arbitrary shader properties. Version upgrades where property path names changed. Reflecting over the serialized Material object expecting BeginProperty to accept all children.","solutions":["Restrict BeginProperty calls to the four known meta property paths; use MaterialProperty.BeginProperty for shader uniforms instead.","Guard with a switch/if on property.propertyPath before calling GetMaterialSerializedProperty and skip unknown paths.","If you must handle arbitrary paths, catch ArgumentException and fall back to the MaterialProperty-based API."],"exampleFix":"// before\nvar msp = GetMaterialSerializedProperty(prop); // throws on unknown path\nMaterialEditor.BeginProperty(msp, targets);\n\n// after\nMaterialProperty matProp = MaterialEditor.GetMaterialProperty(targets, prop.propertyPath);\nif (matProp != null)\n    MaterialEditor.BeginProperty(matProp, targets);","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> s_KnownPaths = new HashSet<string> {\n    \"m_LightmapFlags\", \"m_EnableInstancingVariants\", \"m_DoubleSidedGI\", \"m_CustomRenderQueue\"\n};\nbool CanBeginProperty(SerializedProperty p) => s_KnownPaths.Contains(p.propertyPath);","typeGuard":"// n/a: discrimination is by string value, not type\nstatic bool IsKnownMaterialPath(SerializedProperty p) =>\n    p.propertyPath == \"m_LightmapFlags\" || p.propertyPath == \"m_EnableInstancingVariants\"\n    || p.propertyPath == \"m_DoubleSidedGI\" || p.propertyPath == \"m_CustomRenderQueue\";","tryCatchPattern":"try { MaterialEditor.BeginProperty(GetMaterialSerializedProperty(prop), targets); }\ncatch (ArgumentException) { /* fall back to MaterialProperty.BeginProperty */ }","preventionTips":["Route only the four material-meta paths through BeginProperty.","Use MaterialProperty.BeginProperty for shader uniforms.","Centralize property-path routing in a single helper."],"tags":["unity","editor","material","serializedproperty","shadergui"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}