Skip to content

Game.Settings.KeybindingSettings

Assembly:
Assembly-CSharp.dll

Namespace:
Game.Settings

Type:
class

Base:
Setting

Summary:
Represents saved keybinding settings and acts as a lightweight wrapper around the game's InputManager. This class can be created in two modes: - Default mode (isDefault = true): exposes the original/built-in bindings for inspection (getter returns original bindings) but does not apply changes (setter is a no-op). - Normal mode (isDefault = false): exposes the effective bindings and allows applying a new set of bindings back into InputManager.

This class is annotated with [FileLocation("Settings")] so it is stored/loaded from the Settings location, and its bindings property is hidden from the settings UI via [SettingsUIHidden]. It relies on Game.Input.InputManager and ProxyBinding types.


Fields

  • private bool m_IsDefault
    Indicates whether this settings instance represents the original/default bindings (true) or the effective/current bindings (false). When true, writing to the bindings property will be ignored.

Properties

  • public List<ProxyBinding> bindings { get; set; }
    Hidden from the settings UI ([SettingsUIHidden]). Getter: returns a List obtained from InputManager.instance.GetBindings(...). If m_IsDefault is true, it requests InputManager.PathType.Original (the built-in/original bindings); otherwise it requests InputManager.PathType.Effective (the currently effective bindings). The getter also filters using InputManager.BindingOptions.OnlyRebound | InputManager.BindingOptions.OnlyBuiltIn and converts the result to a List via LINQ ToList(). Setter: if m_IsDefault is false, forwards the provided list to InputManager.instance.SetBindings(value, out var _), writing the new bindings into the input manager; if m_IsDefault is true, the setter does nothing.

Constructors

  • public KeybindingSettings(bool isDefault = false)
    Creates a new KeybindingSettings instance. The optional isDefault parameter (default false) sets m_IsDefault. Use isDefault = true when you want to read the original/built-in bindings without allowing changes to be applied.

Methods

  • public override void SetDefaults() : void
    Override is empty. The class does not provide a separate defaulting routine because bindings are managed through InputManager. Implementations that expect SetDefaults to reset values should instead use InputManager APIs directly.

Usage Example

// Inspect original built-in bindings (read-only)
var defaultBindingsSetting = new KeybindingSettings(isDefault: true);
List<ProxyBinding> original = defaultBindingsSetting.bindings;

// Inspect and modify current/effective bindings
var bindingsSetting = new KeybindingSettings(); // isDefault = false
List<ProxyBinding> current = bindingsSetting.bindings;

// Modify an entry in 'current' as needed, then apply back:
 // current[0].Key = KeyCode.F; // example modification
bindingsSetting.bindings = current; // applied to InputManager via SetBindings

// Note: If the instance was created with isDefault = true, assigning to bindings does nothing.

Additional notes: - This class depends on InputManager.instance being available; ensure the input system is initialized before reading/applying bindings. - The setter discards any out parameter from InputManager.SetBindings via "out var _". - The [SettingsUIHidden] attribute means the bindings property will not be shown in the settings UI; use this class programmatically or via a custom UI.