Unity-Technologies/UnityCsReference · error · ArgumentException

The SerializedProperty '{0}' is not supported by BeginProper

Error message

The SerializedProperty '{0}' is not supported by BeginProperty.

What it means

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.

Source

Thrown at Editor/Mono/Inspector/MaterialEditor.cs:1356

            return count;
        }

        static bool AllTargetsAreVariants(Object[] targets)
        {
            return GetVariantCount(targets) == targets.Length;
        }

        static MaterialSerializedProperty GetMaterialSerializedProperty(SerializedProperty property)
        {
            if (property.propertyPath == "m_LightmapFlags")
                return MaterialSerializedProperty.LightmapFlags;
            if (property.propertyPath == "m_EnableInstancingVariants")
                return MaterialSerializedProperty.EnableInstancingVariants;
            if (property.propertyPath == "m_DoubleSidedGI")
                return MaterialSerializedProperty.DoubleSidedGI;
            if (property.propertyPath == "m_CustomRenderQueue")
                return MaterialSerializedProperty.CustomRenderQueue;
            throw new ArgumentException(string.Format("The SerializedProperty '{0}' is not supported by BeginProperty.", property.propertyPath));
        }

        internal static void BeginProperty(MaterialSerializedProperty property, Object[] targets)
        {
            MaterialProperty.BeginProperty(property, targets);
        }

        internal static void BeginProperty(Rect rect, MaterialSerializedProperty property, Object[] targets)
        {
            MaterialProperty.BeginProperty(rect, null, property, targets);
        }

        public static void BeginProperty(SerializedProperty property)
        {
            MaterialProperty.BeginProperty(GetMaterialSerializedProperty(property), property.serializedObject.targetObjects);
        }

        public static void BeginProperty(Rect rect, SerializedProperty property)

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Restrict BeginProperty calls to the four known meta property paths; use MaterialProperty.BeginProperty for shader uniforms instead.
  2. Guard with a switch/if on property.propertyPath before calling GetMaterialSerializedProperty and skip unknown paths.
  3. If you must handle arbitrary paths, catch ArgumentException and fall back to the MaterialProperty-based API.

Example fix

// before
var msp = GetMaterialSerializedProperty(prop); // throws on unknown path
MaterialEditor.BeginProperty(msp, targets);

// after
MaterialProperty matProp = MaterialEditor.GetMaterialProperty(targets, prop.propertyPath);
if (matProp != null)
    MaterialEditor.BeginProperty(matProp, targets);
Defensive patterns

Strategy: validation

Validate before calling

static readonly HashSet<string> s_KnownPaths = new HashSet<string> {
    "m_LightmapFlags", "m_EnableInstancingVariants", "m_DoubleSidedGI", "m_CustomRenderQueue"
};
bool CanBeginProperty(SerializedProperty p) => s_KnownPaths.Contains(p.propertyPath);

Type guard

// n/a: discrimination is by string value, not type
static bool IsKnownMaterialPath(SerializedProperty p) =>
    p.propertyPath == "m_LightmapFlags" || p.propertyPath == "m_EnableInstancingVariants"
    || p.propertyPath == "m_DoubleSidedGI" || p.propertyPath == "m_CustomRenderQueue";

Try / catch

try { MaterialEditor.BeginProperty(GetMaterialSerializedProperty(prop), targets); }
catch (ArgumentException) { /* fall back to MaterialProperty.BeginProperty */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/bd2b2dce7f84684b. Report an issue: GitHub.