Skip to main content

Class SettingsExtensions

Provides extension methods for managing and displaying settings in Unity. These methods include functionalities for retrieving the settings provider, determining the settings scope, and generating labels for settings sections.

public static class SettingsExtensions

Inheritance​

Methods​

GetSettingLabel<T>(Settings<T>)​

Generates a label for the settings section based on its display path. The label is created from the last part of the display path, typically after the last '/'.

public static Label GetSettingLabel<T>(this Settings<T> settings) where T : Settings<T>

Parameters​

NameTypeDescription
settingsSettings<T>The settings instance used to extract the display path for the label.

Returns​

Label — A Label element that can be displayed in the UI with the settings section title.

Type Parameters​

NameTypeDescription
TThe type of settings for which the label is generated.

GetSettingsProvider<T>(Settings<T>)​

Retrieves the SettingsProvider instance used to display settings in Unity's "Edit/Preferences" and "Edit/Project Settings" menus.

public static SettingsProvider GetSettingsProvider<T>(this Settings<T> settings) where T : Settings<T>

Parameters​

NameTypeDescription
settingsSettings<T>The settings instance for which the SettingsProvider is needed.

Returns​

SettingsProvider — A SettingsProvider instance that can be used to display the settings.

Type Parameters​

NameTypeDescription
TThe type of settings being retrieved.

GetSettingsScope(SettingsUsage)​

Retrieves the settings scope corresponding to the specified SettingsUsage. The scope is either User or Project based on the usage type.

public static SettingsScope GetSettingsScope(this SettingsUsage usage)

Parameters​

NameTypeDescription
usageSettingsUsageThe usage type that specifies the context of the settings.

Returns​

SettingsScope — The corresponding SettingsScope: either User or Project.

  • Methods
    • GetSettingLabel<T>(Settings<T>)
    • GetSettingsProvider<T>(Settings<T>)
    • GetSettingsScope(SettingsUsage)