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
- Null-check the SerializedProperty before calling AddNotificationRequest.
- Verify the property path exists on the target type (use FindProperty and check for null) before requesting a notification.
- Ensure the drawer's SerializedObject is valid and initialized before invoking.
- 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
- Null-check SerializedProperty results from FindProperty before forwarding.
- Ensure the serialized object is initialized before requesting notifications.
- Validate property paths exist on the target graphics-settings type.
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
- get function cannot be null
- set function cannot be null
- Dialog message text cannot be null or whitespace.
- The root is null
- gameObjects array is null
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/cb2c1dfaa1de8bdd.
Report an issue: GitHub.