{"record":{"id":"77ddef5bfea9e75c","repo":"Unity-Technologies/UnityCsReference","slug":"the-elementname-argument-can-t-be-null-or-empty","errorCode":null,"errorMessage":"The elementName argument can't be null or empty.","messagePattern":"The elementName argument can't be null or empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorUtility.cs","lineNumber":363,"sourceCode":"        static readonly List<Foldout> k_Foldouts = new();\n\n        public static void OpenAndScrollTo(string propertyPath)\n        {\n            if (string.IsNullOrEmpty(propertyPath))\n                throw new ArgumentException(nameof(propertyPath), $\"The {nameof(propertyPath)} argument can't be null or empty.\");\n\n            OpenAndScrollTo<PropertyField, PropertyField>(\n                root => TryFindPropertyAndTabByBindingPath(propertyPath, root, out var tabbedView, out var tabButton, out var propertyField)\n                    ? (true, tabbedView, tabButton, propertyField)\n                    : (false, null, null, null),\n                () => $\"Couldn't find a property with bindingPath {propertyPath} in the settings container.\",\n                (scrollView, _, propertyField, _) => OpenFoldoutsThenScroll(propertyField, scrollView));\n        }\n\n        public static void OpenAndScrollToElement(string elementName)\n        {\n            if (string.IsNullOrEmpty(elementName))\n                throw new ArgumentException(nameof(elementName), $\"The {nameof(elementName)} argument can't be null or empty.\");\n\n            OpenAndScrollTo<VisualElement, VisualElement>(\n                root => TryFindElementAndTabByName(elementName, root, out var tabbedView, out var tabButton, out var element)\n                    ? (true, tabbedView, tabButton, element)\n                    : (false, null, null, null),\n                () => $\"Couldn't find an element with name {elementName} in the settings container.\",\n                (scrollView, _, element, _) => OpenFoldoutsThenScroll(element, scrollView));\n        }\n\n        public static void OpenAndScrollTo(Type renderPipelineGraphicsSettingsType)\n        {\n            OpenAndScrollTo<PropertyField>(renderPipelineGraphicsSettingsType);\n        }\n\n        public static void OpenAndScrollTo<TGraphicsSettings>(string propertyPath = \"\")\n            where TGraphicsSettings : IRenderPipelineGraphicsSettings\n        {\n            OpenAndScrollTo<TGraphicsSettings, PropertyField>(p => p.bindingPath.Contains(propertyPath));","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/GraphicsSettingsInspectors/GraphicsSettingsInspectorUtility.cs#L345-L381","documentation":"OpenAndScrollToElement navigates to a VisualElement by name; a null/empty elementName cannot match anything, so it throws ArgumentException immediately.","triggerScenarios":"Calling GraphicsSettingsInspectorUtility.OpenAndScrollToElement(null) or OpenAndScrollToElement(\"\").","commonSituations":"Forwarding an element name that was never set. Binding code passing a default/empty string. Looking up by a name field that failed to populate.","solutions":["Check elementName is non-null and non-empty before calling.","Ensure the element you target actually has its name set in UXML/code before invoking.","Use string.IsNullOrWhiteSpace guard at the call site."],"exampleFix":"// before\nOpenAndScrollToElement(null); // throws\n\n// after\nif (!string.IsNullOrWhiteSpace(elementName))\n    OpenAndScrollToElement(elementName);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(elementName))\n    throw new ArgumentException(\"elementName required\", nameof(elementName));\nGraphicsSettingsInspectorUtility.OpenAndScrollToElement(elementName);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure target elements have a name set in UXML/code before navigating to them.","Guard call sites with IsNullOrWhiteSpace."],"tags":["graphics-settings","argument","visual-element","validation"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}