> For the complete documentation index, see [llms.txt](https://docs.sparkframework.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sparkframework.dev/documentation/developer-guide/core-systems/gamesettings/api.md). Agents can also search and read this documentation through its [MCP server](https://docs.sparkframework.dev/~gitbook/mcp).

# API

**Assembly:** `Spark.GameSettings` **Interface:** `IGameSettingsPlugin` **Implementation:** `GameSettingsPlugin`

## Interface

```csharp
public interface IGameSettingsPlugin
{
    // Video
    void SetResolution(int width, int height, FullScreenMode mode);
    int GetResolutionWidth();
    int GetResolutionHeight();
    void SetWindowMode(FullScreenMode mode);
    FullScreenMode GetWindowMode();
    void SetVSync(bool enabled);
    bool GetVSync();
    void SetFrameRateLimit(int limit);
    int GetFrameRateLimit();
    void SetQualityLevel(int level);
    int GetQualityLevel();
    void SetAntiAliasing(int level);
    int GetAntiAliasing();
    void SetTextureQuality(int quality);
    int GetTextureQuality();

    // Audio
    void SetVolume(AudioChannel channel, float volume);
    float GetVolume(AudioChannel channel);
    void SetAudioMixer(AudioMixer mixer);

    // Keybinds
    void RegisterInputActionAsset(InputActionAsset asset);
    void StartInteractiveRebind(string actionId, int bindingIndex,
        Action onComplete, Action onCancel);
    void CancelInteractiveRebind();
    void ResetBinding(string actionId, int bindingIndex);
    void ClearBinding(string actionId, int bindingIndex);
    void ResetAllBindings();
    string GetBindingDisplayString(string actionId, int bindingIndex);
    InputAction FindConflictingBinding(string bindingPath, string excludeActionId);

    // Persistence
    Task SaveSettingsAsync();
    void SaveSettings();
    Task LoadSettingsAsync();
    void ResetToDefaults();

    // Data access
    VideoSettingsData GetVideoSettings();
    AudioSettingsData GetAudioSettings();
    KeybindSettingsData GetKeybindSettings();
}
```

## AudioChannel Enum

```csharp
public enum AudioChannel
{
    Master,
    Music,
    SFX,
    UI
}
```

## Save Data Classes

### VideoSettingsData

Extends `SaveDataEntry`.

| Field              | Type           | Description                         |
| ------------------ | -------------- | ----------------------------------- |
| `resolutionWidth`  | int            | Screen width in pixels              |
| `resolutionHeight` | int            | Screen height in pixels             |
| `windowMode`       | FullScreenMode | Fullscreen, windowed, or borderless |
| `vSyncEnabled`     | bool           | Vertical sync toggle                |
| `frameRateLimit`   | int            | Max framerate (0 = unlimited)       |
| `qualityLevel`     | int            | Unity quality settings index        |
| `antiAliasing`     | int            | Anti-aliasing level                 |
| `textureQuality`   | int            | Texture resolution level            |

### AudioSettingsData

Extends `SaveDataEntry`.

| Field          | Type  | Description                    |
| -------------- | ----- | ------------------------------ |
| `masterVolume` | float | Master volume in dB (-80 to 0) |
| `musicVolume`  | float | Music volume in dB (-80 to 0)  |
| `sfxVolume`    | float | SFX volume in dB (-80 to 0)    |
| `uiVolume`     | float | UI volume in dB (-80 to 0)     |

### KeybindSettingsData

Extends `SaveDataEntry`.

| Field            | Type                            | Description                |
| ---------------- | ------------------------------- | -------------------------- |
| `assetOverrides` | List\<InputActionAssetOverride> | Per-asset rebind overrides |

Each `InputActionAssetOverride` contains:

| Field           | Type   | Description                  |
| --------------- | ------ | ---------------------------- |
| `assetGuid`     | string | GUID of the InputActionAsset |
| `assetName`     | string | Human-readable asset name    |
| `overridesJson` | string | Serialized rebind data       |

## Events

| Event                     | Description                                   |
| ------------------------- | --------------------------------------------- |
| `KeybindChangedEvent`     | Published when a keybind is rebound           |
| `GameSettingsLoadedEvent` | Published after settings are loaded from disk |

## Usage

```csharp
var settings = Spark.GetPlugin<IGameSettingsPlugin>();
if (settings != null)
{
    // Audio
    settings.SetVolume(AudioChannel.Master, -10f);
    float masterVol = settings.GetVolume(AudioChannel.Master);

    // Video
    settings.SetResolution(1920, 1080, FullScreenMode.FullScreenWindow);
    settings.SetVSync(true);

    // Keybinds
    settings.RegisterInputActionAsset(myInputActions);
    settings.StartInteractiveRebind("Jump", 0,
        onComplete: () => Debug.Log("Rebound!"),
        onCancel: () => Debug.Log("Cancelled"));

    // Save
    await settings.SaveSettingsAsync();
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sparkframework.dev/documentation/developer-guide/core-systems/gamesettings/api.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
