Skip to content

Game.Settings.SettingsUIMouseBindingAttribute

Assembly: Assembly-CSharp
Namespace: Game.Settings

Type: class

Base: SettingsUIKeybindingAttribute

Summary:
Attribute used to declare a mouse input binding for the settings UI. It targets mouse device bindings and lets the modder specify a default mouse button (BindingMouse) and optional keyboard modifiers (shift, ctrl, alt). The attribute also exposes the input-system control path for the chosen mouse button and yields modifier control paths for building composite bindings. It supports Button, Axis and Vector2 action types via different constructors.


Fields

  • public readonly BindingMouse defaultKey
    Specifies the default mouse button for the binding (e.g., Left, Right, Middle, Forward, Backward, or None). This value is used by the attribute's control property to produce the appropriate input-system control path.

  • public readonly bool alt
    If true, the Alt modifier is required/considered for this binding. Used by modifierControls to include "/alt".

  • public readonly bool ctrl
    If true, the Ctrl modifier is required/considered for this binding. Used by modifierControls to include "/ctrl".

  • public readonly bool shift
    If true, the Shift modifier is required/considered for this binding. Used by modifierControls to include "/shift".

Properties

  • public override string control { get; }
    Maps the selected BindingMouse value to an input-system control path string. Mapping implemented:

  • BindingMouse.None => string.Empty

  • BindingMouse.Left => "/leftButton"
  • BindingMouse.Middle => "/middleButton"
  • BindingMouse.Right => "/rightButton"
  • BindingMouse.Forward => "/forwardButton"
  • BindingMouse.Backward => "/backButton"

Returns an empty string for None or unrecognized values. This path is what the input system binds to for the mouse button.

  • public override IEnumerable<string> modifierControls { get; }
    Yields additional control paths for required modifier keys. The implementation yields in this order:
  • If shift == true => "/shift"
  • If ctrl == true => "/ctrl"
  • If alt == true => "/alt"

Consumers can use the yielded strings to create composite bindings that require one or more modifiers together with the mouse control.

Constructors

  • public SettingsUIMouseBindingAttribute(string actionName = null)
    Creates a mouse button binding attribute defaulting to a Button action of component Press. Delegates to base with InputManager.DeviceType.Mouse, ActionType.Button and ActionComponent.Press. Use this when you want a simple button binding and will set defaultKey via another constructor overload.

  • public SettingsUIMouseBindingAttribute(AxisComponent component, string actionName = null)
    Creates an attribute for an Axis action using the provided AxisComponent. Delegates to base with ActionType.Axis and casts the component to ActionComponent.

  • public SettingsUIMouseBindingAttribute(Vector2Component component, string actionName = null)
    Creates an attribute for a Vector2 action using the provided Vector2Component. Delegates to base with ActionType.Vector2 and casts the component to ActionComponent.

  • public SettingsUIMouseBindingAttribute(BindingMouse defaultKey, string actionName = null, bool alt = false, bool ctrl = false, bool shift = false)
    Convenience constructor that sets a default mouse button and optional modifier booleans. Internally calls the button-action constructor, then assigns defaultKey, alt, ctrl, and shift fields.

  • public SettingsUIMouseBindingAttribute(BindingMouse defaultKey, AxisComponent component, string actionName = null, bool alt = false, bool ctrl = false, bool shift = false)
    Combination constructor for an Axis action that also sets default mouse button and modifiers. Delegates to the Axis-component constructor, then assigns defaultKey and modifier flags.

  • public SettingsUIMouseBindingAttribute(BindingMouse defaultKey, Vector2Component component, string actionName = null, bool alt = false, bool ctrl = false, bool shift = false)
    Combination constructor for a Vector2 action that also sets default mouse button and modifiers. Delegates to the Vector2-component constructor, then assigns defaultKey and modifier flags.

Notes on parameters: - actionName (string): optional logical name of the action this binding belongs to. - defaultKey (BindingMouse): default mouse button to use for the binding. - alt/ctrl/shift (bool): whether the respective keyboard modifier should be included.

Methods

  • None (the class exposes only properties and constructors; behavior is implemented via property getters and constructor initialization).

Usage Example

// Simple button binding: right mouse button, requires Ctrl
[SettingsUIMouseBinding(BindingMouse.Right, actionName: "PanCamera", ctrl: true)]
public SettingsUIKeybinding panCameraBinding;

// Axis binding example: use mouse axis component (example enum value) with a default middle button (if applicable)
[SettingsUIMouseBinding(BindingMouse.Middle, AxisComponent.X, actionName: "ScrollAxis")]
public SettingsUIKeybinding scrollAxisBinding;

// Vector2 binding example: no default button, used for two-dimensional mouse input (e.g., pointer delta)
[SettingsUIMouseBinding(BindingMouse.None, Vector2Component.Delta, actionName: "PointerDelta")]
public SettingsUIKeybinding pointerDeltaBinding;

Additional notes: - The attribute relies on the underlying SettingsUIKeybindingAttribute and InputManager types (DeviceType.Mouse, ActionType, ActionComponent enums). It is intended for use in the game's settings UI code to declare default bindings and control paths for mouse-based actions.