Skip to content

Game.SharedSettings

Assembly: Assembly-CSharp
Namespace: Game.Settings

Type: class

Base: System.Object

Summary:
SharedSettings centralizes all user-configurable settings groups for the game (general, audio, graphics, input, gameplay, editor, interface, keybindings, modding, radio and user state). It constructs and stores each Setting-derived group, loads their saved values from the global AssetDatabase, registers options UI sections, and provides bulk operations (Apply / Reset). It also wires up runtime event handlers to re-register input-related UI when devices or control schemes change.


Fields

  • private readonly System.Collections.Generic.List<Setting> m_Settings
    Holds the collection of all Setting instances created by the SharedSettings constructor. Used to iterate and perform bulk operations such as Load, Apply and Reset for every setting group.

Properties

  • public static SharedSettings instance { get; }
    Returns the current SharedSettings instance from GameManager.instance?.settings. Useful for mod code that needs to access the game's live settings manager.

  • public GeneralSettings general { get; private set; }
    The General settings group (game-wide options).

  • public AudioSettings audio { get; private set; }
    Audio-related settings (volume levels, output, etc).

  • public GameplaySettings gameplay { get; private set; }
    Gameplay-specific options (simulation and game rules).

  • public RadioSettings radio { get; private set; }
    Settings for in-game radio behavior.

  • public GraphicsSettings graphics { get; private set; }
    Graphics and visual quality settings.

  • public EditorSettings editor { get; private set; }
    Settings used by in-game editor tools.

  • public InterfaceSettings userInterface { get; private set; }
    User interface related settings, including locale; used to set active localization.

  • public InputSettings input { get; private set; }
    Input device and input-related settings.

  • public KeybindingSettings keybinding { get; private set; }
    Keybinding and binding persistence settings.

  • public ModdingSettings modding { get; private set; }
    Options exposed for mod behavior and modding-related toggles.

  • public UserState userState { get; private set; }
    Per-user runtime state persisted separately from other settings (loaded by LoadUserSettings).

Constructors

  • public SharedSettings(LocalizationManager localizationManager)
    Creates all Setting groups, adds them to the internal list (m_Settings), then calls LoadSettings() to populate them from the AssetDatabase. It also calls LauncherSettings.LoadSettings(localizationManager, this) to allow launcher-provided values, and sets the active locale in the provided LocalizationManager using userInterface.locale. The constructor is the primary place where all setting groups are instantiated and initial loading occurs.

Methods

  • public void RegisterInOptionsUI()
    Registers each settings group into the options UI under named sections:
  • "General", "Graphics", "Gameplay", "Interface", "Audio", "Input", "Modding" (and "Editor" was constructed but not explicitly registered here).
  • When GameManager.instance.configuration.developerMode is enabled, an "About" section is created and re-registered when PlatformManager.instance.onStatusChanged fires.
  • Subscribes to InputSystem.onDeviceChange and Game.Input.InputManager.instance.EventControlSchemeChanged to re-register the Input options UI when input devices are added/removed or control scheme changes. Uses local functions as event handlers to call input.RegisterInOptionsUI("Input").

  • public void LoadSettings()
    Loads the persistent settings for each group from AssetDatabase.global using known keys:

  • "General Settings", "Audio Settings", "Gameplay Settings", "Radio Settings", "Graphics Settings", "Editor Settings", "Interface Settings", "Input Settings", "Keybinding Settings", "Modding Settings".
  • Default instances are provided for most loads, ensuring sensible defaults if no saved data exists.

  • public void LoadUserSettings()
    Loads per-user persistent state from AssetDatabase.global using the key "User Settings" with a default UserState instance.

  • public void Reset()
    Performs a factory reset for all managed settings:

  • Calls Launcher.DeleteLastSaveMetadata() to clear last save metadata.
  • Iterates m_Settings and for each Setting calls SetDefaults() followed by ApplyAndSave() to persist the defaults.

  • public void Apply()
    Applies all settings in m_Settings by iterating and calling setting.Apply() on each. This triggers runtime application of options without necessarily saving them.

Usage Example

// Access the global SharedSettings instance (created by GameManager)
var shared = SharedSettings.instance;

// Register settings UI (normally called during initialization)
shared?.RegisterInOptionsUI();

// Force-apply all settings at runtime
shared?.Apply();

// Reset all settings to defaults and persist them
shared?.Reset();

// If you are constructing your own SharedSettings (usually managed by GameManager):
var localizationManager = /* obtain LocalizationManager instance */;
var mySharedSettings = new SharedSettings(localizationManager);
mySharedSettings.RegisterInOptionsUI();

Additional notes: - SharedSettings expects Setting-derived classes (GeneralSettings, AudioSettings, etc.) to implement SetDefaults, Apply, and ApplyAndSave appropriately. - Most code paths rely on GameManager and other singletons; for mods prefer accessing SharedSettings.instance rather than constructing a new instance, unless intentionally replacing behavior for testing.