Unity-Technologies/UnityCsReference · error · ArgumentException

Property cannot be null.

Error message

Property cannot be null.

What it means

AddNotificationRequest requires a non-null SerializedProperty to compute data-equality against the previous state and to enqueue a notification. A null property throws ArgumentException (note: it uses ArgumentException rather than ArgumentNullException, and also passes the property name as the paramName).

Source

Thrown at Editor/Mono/Inspector/GraphicsSettingsInspectors/RenderPipelineGraphicsSettingsPropertyDrawer.cs:234

            EditorGraphicsSettings.ForEachPipelineSettings(gs => {
                if (gs != null)
                    s_SharedPreviousStates[gs.GetType()] = new SerializedObject(gs);
            });
        }

        static void UpdatePreviousState(SerializedProperty property)
            => GetPreviousState(property).Update();

        static SerializedObject GetPreviousState(SerializedProperty property)
        {
            var type = property.serializedObject.targetObject.GetType();
            return s_SharedPreviousStates[type];
        }

        static public void AddNotificationRequest(SerializedProperty property)
        {
            if (property == null)
                throw new ArgumentException("Property cannot be null.", $"{nameof(property)}");

            //If GraphicsSettings window was open when project open, s_SharedPreviousStates can still be null when we call this.
            if (s_SharedPreviousStates == null)
                RecomputeDictionary();
            
            bool dataEquals = SerializedProperty.DataEquals(property, GetPreviousState(property).FindProperty(property.propertyPath));
            if (dataEquals && !s_Scoped)
                return;

            NotificationRequest candidate = new(property);
            if (dataEquals && s_NotificationRequests.Contains(candidate))
                return;

            UpdatePreviousState(property);
            Register(candidate);
        }

        static void Register(NotificationRequest verifiedRequest)

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Null-check the SerializedProperty before calling AddNotificationRequest.
  2. Verify the property path exists on the target type (use FindProperty and check for null) before requesting a notification.
  3. Ensure the drawer's SerializedObject is valid and initialized before invoking.
  4. If you control the caller, short-circuit when FindProperty returns null instead of forwarding.

Example fix

// before
AddNotificationRequest(serializedObject.FindProperty("missingPath")); // null -> throws

// after
var prop = serializedObject.FindProperty(path);
if (prop != null) AddNotificationRequest(prop);
Defensive patterns

Strategy: validation

Validate before calling

var prop = serializedObject.FindProperty(path);
if (prop == null) return; // path does not exist on this type
RenderPipelineGraphicsSettingsPropertyDrawer.AddNotificationRequest(prop);

Try / catch

try { AddNotificationRequest(prop); }
catch (ArgumentException) { /* prop null/invalid; skip notification */ }

Prevention

When it happens

Trigger: Calling RenderPipelineGraphicsSettingsPropertyDrawer.AddNotificationRequest(null) or with a property that resolved to null from a FindProperty call upstream.

Common situations: A property path lookup (SerializedObject.FindProperty) returning null because the path doesn't exist on the graphics-settings type, then forwarding it to AddNotificationRequest. Drawer code running before the serialized object is fully initialized.

Related errors


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