Declare settings
Declare a page
Inherit SettingsPage once per page. It appears in Project Settings, in Preferences, or in both,
depending on the kinds of settings it holds.
public sealed class GamePage : SettingsPage
{
public override string Path => "My Game";
public override string Description => "Runtime tunables.";
public override string HelpUrl => "https://docs.example.com";
}
| Property | Description |
|---|---|
| Path | Where the page appears in the list. Use / to nest it, for example "My Game/Networking". Required. |
| Description | A short text at the top of the page. Optional. |
| HelpUrl | Adds a "?" button that opens this link. Optional. |
Path constant. It is read once per editor session, so a path that changes during a session doesn't move the page until Unity restarts.Write a settings class
A settings class holds the values of one section on a page. To write one:
- Inherit one of the four base classes, with your page as the type argument.
- Mark it
[System.Serializable]. - Give it a parameterless constructor (the default one is fine).
- Store its values in
[SerializeField]fields.
[System.Serializable]
public sealed class AudioDefaults : BuildSettingsEntry<GamePage>
{
[SerializeField, Range(0f, 1f)] float masterVolume = 0.8f;
public float MasterVolume => masterVolume;
}
Each field's initializer sets its default value: the value a new project starts with, and the value Revert to Default restores. A field can also reference a project asset, such as a texture or a ScriptableObject; in a build setting, the asset is included in the build along with it.
Choose a kind of setting
The base class decides where a setting appears and whether it reaches your builds:
| Base class | Window | Shared with the team | In builds | Use it for |
|---|---|---|---|---|
BuildSettingsEntry<TPage> | Project Settings | Yes | Yes | Values your game or package reads at runtime. |
PlatformSettingsEntry<TPage> | Project Settings | Yes | Yes, per platform | Values that differ per platform, like a server URL. |
EditorSettingsEntry<TPage> | Project Settings | Yes | No | Options for your editor tools. |
UserSettingsEntry<TPage> | Preferences | No | No | Personal options, like a highlight color. |
ProjectSettings/SettingsKit.asset and user settings in UserSettings/SettingsKit.asset. With Unity's standard .gitignore, the first is shared with your team and the second stays on each machine, with nothing to set up.A per-platform setting gets a row of tabs in its section. Default holds the values every platform uses; select + to give a platform its own values, and - to remove them. A read returns the values for the platform the game runs on, which in the editor is the active build target.