{"record":{"id":"bcdc0021aaed7145","repo":"Unity-Technologies/UnityCsReference","slug":"the-setting-label-can-t-be-null-or-empty","errorCode":null,"errorMessage":"The setting label can't be null or empty.","messagePattern":"The setting label can't be null or empty\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsInspectorUtility.cs","lineNumber":53,"sourceCode":"        }\n\n        [AutoStaticsCleanupOnCodeReload]\n        static EditorApplication.CallbackFunction s_ActiveReveal;\n\n        /// <summary>\n        /// Opens the player settings, expands the given section, and scrolls to the given setting.\n        /// </summary>\n        /// <remarks>\n        /// Opens the Player section of the Project Settings window on the active build target's tab. When the active build profile has its own player settings, opens the Build Profiles window instead, without scrolling. The setting is found by the label it draws in the expanded section, so it only reaches settings that are directly visible there: settings nested inside a foldout within the section, sections added by platform extensions, and sections or settings that don't exist for the active platform are not reachable. When the setting is not found, the window still opens and a warning is logged.\n        /// </remarks>\n        /// <param name=\"section\">The section that contains the setting.</param>\n        /// <param name=\"settingLabel\">The label of the setting, as shown in the inspector, in English.</param>\n        /// <exception cref=\"ArgumentException\">Thrown when the setting label is null or empty.</exception>\n        /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when the section is not a valid <see cref=\"Section\"/> value.</exception>\n        public static void OpenAndScrollTo(Section section, string settingLabel)\n        {\n            if (string.IsNullOrEmpty(settingLabel))\n                throw new ArgumentException(\"The setting label can't be null or empty.\", nameof(settingLabel));\n\n            // Decouples the published enum values from the accordion draw order in PlayerSettingsEditor.OnInspectorGUI.\n            int sectionIndex = section switch\n            {\n                Section.Icon => 0,\n                Section.ResolutionAndPresentation => 1,\n                Section.SplashImage => 2,\n                Section.DebuggingAndCrashReporting => 3,\n                Section.OtherSettings => 4,\n                Section.PublishingSettings => 5,\n                _ => throw new ArgumentOutOfRangeException(nameof(section)),\n            };\n\n            if (BuildProfileContext.ProjectHasActiveProfileWithPlayerSettings())\n            {\n                // The active build profile owns the player settings; the global page can't change the effective values.\n                BuildPipeline.ShowBuildProfileWindow();\n                return;","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsInspectorUtility.cs#L35-L71","documentation":"Thrown by PlayerSettingsInspectorUtility.OpenAndScrollTo when settingLabel is null or empty. The method needs a non-empty label string to locate the setting in the inspector section.","triggerScenarios":"Calling OpenAndScrollTo(section, label) with a null, empty, or whitespace-only label string. Passing a localized label variable that resolved to empty.","commonSituations":"Automation that navigates to a setting by name but the name string is misconfigured or unlocalized. Refactoring that drops the label argument.","solutions":["Pass a non-empty setting label matching the English text shown in the inspector section.","Validate settingLabel with string.IsNullOrWhiteSpace before calling OpenAndScrollTo.","If the label is data-driven, ensure the source provides a value for this setting."],"exampleFix":"// before\nPlayerSettingsInspectorUtility.OpenAndScrollTo(section, label);\n\n// after\nif (!string.IsNullOrWhiteSpace(label))\n    PlayerSettingsInspectorUtility.OpenAndScrollTo(section, label);\nelse\n    Debug.LogWarning(\"Setting label was empty; not scrolling.\");","handlingStrategy":"validation","validationCode":"bool ok = !string.IsNullOrWhiteSpace(settingLabel);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate settingLabel with IsNullOrWhiteSpace.","Keep label strings non-empty and English."],"tags":["unity","editor","player-settings","validation","argument"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}