Unity-Technologies/UnityCsReference · error · ArgumentException
The setting label can't be null or empty.
Error message
The setting label can't be null or empty.
What it means
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.
Source
Thrown at Editor/Mono/Inspector/PlayerSettingsEditor/PlayerSettingsInspectorUtility.cs:53
}
[AutoStaticsCleanupOnCodeReload]
static EditorApplication.CallbackFunction s_ActiveReveal;
/// <summary>
/// Opens the player settings, expands the given section, and scrolls to the given setting.
/// </summary>
/// <remarks>
/// 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.
/// </remarks>
/// <param name="section">The section that contains the setting.</param>
/// <param name="settingLabel">The label of the setting, as shown in the inspector, in English.</param>
/// <exception cref="ArgumentException">Thrown when the setting label is null or empty.</exception>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the section is not a valid <see cref="Section"/> value.</exception>
public static void OpenAndScrollTo(Section section, string settingLabel)
{
if (string.IsNullOrEmpty(settingLabel))
throw new ArgumentException("The setting label can't be null or empty.", nameof(settingLabel));
// Decouples the published enum values from the accordion draw order in PlayerSettingsEditor.OnInspectorGUI.
int sectionIndex = section switch
{
Section.Icon => 0,
Section.ResolutionAndPresentation => 1,
Section.SplashImage => 2,
Section.DebuggingAndCrashReporting => 3,
Section.OtherSettings => 4,
Section.PublishingSettings => 5,
_ => throw new ArgumentOutOfRangeException(nameof(section)),
};
if (BuildProfileContext.ProjectHasActiveProfileWithPlayerSettings())
{
// The active build profile owns the player settings; the global page can't change the effective values.
BuildPipeline.ShowBuildProfileWindow();
return;View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
PlayerSettingsInspectorUtility.OpenAndScrollTo(section, label);
// after
if (!string.IsNullOrWhiteSpace(label))
PlayerSettingsInspectorUtility.OpenAndScrollTo(section, label);
else
Debug.LogWarning("Setting label was empty; not scrolling."); Defensive patterns
Strategy: validation
Validate before calling
bool ok = !string.IsNullOrWhiteSpace(settingLabel);
Prevention
- Validate settingLabel with IsNullOrWhiteSpace.
- Keep label strings non-empty and English.
When it happens
Trigger: Calling OpenAndScrollTo(section, label) with a null, empty, or whitespace-only label string. Passing a localized label variable that resolved to empty.
Common situations: Automation that navigates to a setting by name but the name string is misconfigured or unlocalized. Refactoring that drops the label argument.
Related errors
- Attempting to set an incorrect number of icons for {namedBui
- Invalid search: cannot be null or empty
- Missing name for {0}
- Scripting backend value {scriptingBackend} is not supported.
- renderingLayerNames is null or empty
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/bcdc0021aaed7145.
Report an issue: GitHub.