Skip to content

Game.Input.BindingMouse

Assembly: Assembly-CSharp.dll
Namespace: Game.Input

Type: enum

Base: System.Enum

Summary: Represents mouse button bindings used by the game's input layer. The enum provides symbolic names for common mouse buttons (left, right, middle) and additional side buttons (forward, backward). Use these values in input handling, binding UI, and settings to avoid relying on raw integer indices.


Fields

  • None = 0
    Represents no mouse button / unbound state.

  • Left = 1
    Primary (left) mouse button. Note: the numeric values in this enum are not the same as UnityEngine.Input mouse-button indices (Unity uses 0 for left). Treat the enum symbolically and convert when interfacing with Unity APIs.

  • Middle = 3
    Middle mouse button (wheel click).

  • Right = 2
    Secondary (right) mouse button.

  • Forward = 4
    Extra forward side button found on some mice (often Mouse4).

  • Backward = 5
    Extra backward side button found on some mice (often Mouse5).

Properties

  • This enum defines no properties.
    Use the enum members directly.

Constructors

  • Enum default: BindingMouse has the implicit enum constructor. The default value is BindingMouse.None (0).

Methods

  • This enum defines no methods. Use it in switch statements, comparisons, or convert to an integer when required.

Usage Example

// Example: checking a binding in Update
private BindingMouse currentBinding = BindingMouse.Left;

void Update()
{
    // When mapping to Unity's Input.GetMouseButtonDown, convert enum to Unity index.
    // Unity uses 0 = Left, 1 = Right, 2 = Middle.
    int unityIndex = ToUnityIndex(currentBinding);
    if (unityIndex >= 0 && Input.GetMouseButtonDown(unityIndex))
    {
        // Handle the bound mouse action
        HandleMouseAction(currentBinding);
    }
}

private int ToUnityIndex(BindingMouse b)
{
    return b switch
    {
        BindingMouse.Left => 0,
        BindingMouse.Right => 1,
        BindingMouse.Middle => 2,
        // Forward/Backward may not be available via Input.GetMouseButton on all platforms;
        // they are usually treated as extra buttons (Mouse3/Mouse4) if supported.
        BindingMouse.Forward => 3,
        BindingMouse.Backward => 4,
        _ => -1
    };
}

private void HandleMouseAction(BindingMouse b)
{
    switch (b)
    {
        case BindingMouse.Left:
            // primary action
            break;
        case BindingMouse.Right:
            // context action
            break;
        case BindingMouse.Middle:
            // special action
            break;
        case BindingMouse.Forward:
        case BindingMouse.Backward:
            // navigate or custom action
            break;
    }
}

Notes: - Prefer using the enum values instead of hard-coded integers for clarity and future-proofing. - When interfacing with Unity's input APIs, verify and adjust indices because Unity's mouse-button numbering is 0-based (Left=0, Right=1, Middle=2), whereas this enum uses different integer assignments.