Unity-Technologies/UnityCsReference · error · ArgumentException

The propertyPath argument can't be null or empty.

Error message

The propertyPath argument can't be null or empty.

What it means

OpenAndScrollTo requires a propertyPath to locate a field in the Graphics Settings UI; an empty or null path is meaningless for the lookup, so it throws ArgumentException up front.

Source

Thrown at Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorUtility.cs:350

        #endregion

        #region OpenAndScrollTo

        const string highlightableClass = "graphics-settings__highlightable";
        const string highlightableColorClass = "graphics-settings__highlightable--background-color";

        [NoAutoStaticsCleanup] // transient event-depth counter reset to 0 at the start of each OpenAndScrollTo; a persisted value is harmless
        static int s_EventCounter;
        [AutoStaticsCleanupOnCodeReload]
        static VisualElement s_SearchedElement;
        [AutoStaticsCleanupOnCodeReload]
        static readonly List<Foldout> k_Foldouts = new();

        public static void OpenAndScrollTo(string propertyPath)
        {
            if (string.IsNullOrEmpty(propertyPath))
                throw new ArgumentException(nameof(propertyPath), $"The {nameof(propertyPath)} argument can't be null or empty.");

            OpenAndScrollTo<PropertyField, PropertyField>(
                root => TryFindPropertyAndTabByBindingPath(propertyPath, root, out var tabbedView, out var tabButton, out var propertyField)
                    ? (true, tabbedView, tabButton, propertyField)
                    : (false, null, null, null),
                () => $"Couldn't find a property with bindingPath {propertyPath} in the settings container.",
                (scrollView, _, propertyField, _) => OpenFoldoutsThenScroll(propertyField, scrollView));
        }

        public static void OpenAndScrollToElement(string elementName)
        {
            if (string.IsNullOrEmpty(elementName))
                throw new ArgumentException(nameof(elementName), $"The {nameof(elementName)} argument can't be null or empty.");

            OpenAndScrollTo<VisualElement, VisualElement>(
                root => TryFindElementAndTabByName(elementName, root, out var tabbedView, out var tabButton, out var element)
                    ? (true, tabbedView, tabButton, element)
                    : (false, null, null, null),

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Validate propertyPath is non-null and non-empty before calling.
  2. Resolve the property path from a known SerializedProperty.propertyPath rather than guessing.
  3. Guard callers that may pass user/empty input with a string.IsNullOrWhiteSpace check.

Example fix

// before
OpenAndScrollTo(""); // throws

// after
if (!string.IsNullOrWhiteSpace(propertyPath))
    OpenAndScrollTo(propertyPath);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(propertyPath))
    throw new ArgumentException("propertyPath required", nameof(propertyPath));
GraphicsSettingsInspectorUtility.OpenAndScrollTo(propertyPath);

Prevention

When it happens

Trigger: Calling GraphicsSettingsInspectorUtility.OpenAndScrollTo(null) or OpenAndScrollTo("").

Common situations: Passing a computed property path that turned out empty (e.g. a name not resolved upstream). UI binding code forwarding an unset field reference. Default/placeholder values reaching the call.

Related errors


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