Class AirshipInputSingleton

Access using Airship.Input. Input singleton contains functions to work with player input (including mouse, keyboard, and touch screen).

Ex:

Airship.Input.CreateAction("Attack", Binding.MouseButton(MouseButton.LeftButton));
Airship.Input.OnDown("Attack").Connect(() => {
print("Attacked!");
});

Properties

actionDownSignals: Map<string, Signal<[event: InputActionEvent]>[]> = ...

Mapping of action name to down signal listeners.

actionDownState: Set<string> = ...

All actions that are currently down.

actionTable: Map<string, InputAction[]> = ...
actionToMobileButtonTable: Map<string, GameObject[]> = ...

Mapping of action names to associated mobile buttons.

actionUpSignals: Map<string, Signal<[event: InputActionEvent]>[]> = ...

Mapping of action name to up signal listeners.

controlManager: Preferred = ...
gameSensitivityMultiplier: number = 1

Sensitivty multiplier maintained by game.

keyboard: Keyboard = ...

Input singleton keyboard instance.

mobileButtonPrefab: GameObject = ...

The default mobile button prefab.

mobileControlsContainer: GameObject

Container that holds mobile control buttons.

mouse: Mouse = ...

Input singleton mouse instance.

onActionBound: Signal<InputAction> = ...

This signal fires when an action is bound, either through code or through the keybind menu.

onActionUnbound: Signal<InputAction> = ...

This signal fires when an action is unbound, either through code or through the keybind menu.

unsetOnDuplicateKeybind: boolean = false

Whether or not creating a duplicate keybind should immediately unbind matching keybinds.

Methods

  • Adds the provided InputAction to the internal action table.

    Parameters

    • action: InputAction

      An InputAction.

    Returns void

  • Clears all signals that have been destroyed.

    Parameters

    • actionName: string

      An action name.

    • actionDirection: InputActionDirection

      The input direction of signals being cleared.

    • signalIndices: number[]

      The indices of signals that are ready to be cleared.

    • signals: Signal<[event: InputActionEvent]>[]

      The signal set that is being modified.

    Returns void

  • Creates an action with respect to the provided name and binding. After this action is created, it will immediately start firing up and down events. This action's binding can be updated through Airship's keybind menu.

    Parameters

    • name: string

      The name of this action.

    • binding: Binding

      The Binding associated with this action. Use Binding.Key to bind this action to a keyboard key, use Binding.MouseButton to bind this action to a mouse button.

    • Optional config: InputActionConfig

    Returns void

  • Creates listeners for provided InputAction based on it's binding.

    Parameters

    • action: InputAction

      An InputAction.

    Returns void

  • Creates an action for each provided schema.

    Parameters

    • actions: InputActionSchema[]

      A collection of InputActionSchemas.

    Returns void

  • Creates a mobile button that triggers the provided action.

    Parameters

    • actionName: string

      The name of the action this button is associated with.

    • anchoredPosition: Vector2

      The anchored position of this button.

    • Optional config: MobileButtonConfig

      A MobileButtonConfig that describes the look and feel of this button.

    Returns void

  • Creates mobile UI canvas container.

    Returns void

  • Creates a ProximityPrompt that fires action events when interacted with. Pressing the prompt's activation key while in range will fire the InputActionDirection.Up event, and releasing it will fire the InputActionDirection.Down event.

    Parameters

    • actionName: string

      The action name associated with this prompt.

    • Optional parent: Transform

      An optional parent Transform that this prompt will live underneath.

    • Optional config: {
          maxRange?: number;
          primaryText?: string;
          secondaryText?: string;
      }

      A ProximityPrompt configuration. Describes prompt text and distance required to activate.

      • Optional maxRange?: number
      • Optional primaryText?: string
      • Optional secondaryText?: string

    Returns default

    The created ProximityPrompt.

  • Returns the InputAction that matches the provided name and type. This function is useful when an action has multiple bindings of different types associated with it.

    Parameters

    • name: string

      An action name.

    • inputType: ActionInputType

      An ActionInputType.

    Returns undefined | InputAction

    The InputAction that matches the provided name and type, if it exists, otherwise undefined.

  • Returns all InputActions associated with the provided name. Use the returned InputActions to unset and modify action bindings.

    Parameters

    • name: string

      An action name.

    Returns InputAction[]

    All InputActions associated with the provided name.

  • Returns all active InputActions.

    Returns InputAction[]

    All active InputActions.

  • Returns mouse sensitivity based on player's setting & game's sensitivity multiplier.

    Returns number

    Mouse sensitivity based on player's setting & game's sensitivity multiplier.

  • Returns mouse smoothing (0 is no smoothing).

    Returns number

    Mouse smoothing (0 is no smoothing).

  • Returns touch sensitivity based on player's setting & game's sensitivity multiplier.

    Returns number

    Touch sensitivity based on player's setting & game's sensitivity multiplier.

  • Hides all mobile buttons that trigger the action name.

    Parameters

    • name: string

      An action name.

    Returns void

  • Returns whether or not the provided action is in the down state.

    Parameters

    • name: string

      An action name.

    Returns boolean

    Whether or not the provided action is the down state.

  • Returns whether or not the provided action is in the up state.

    Parameters

    • name: string

      An action name.

    Returns boolean

  • Creates and returns a new Signal that is fired when the provided action enters the down state.

    Parameters

    • name: string

      An action name.

    Returns Signal<[event: InputActionEvent]>

    A Signal that can be connected to, to listen for action down events.

  • Creates and returns a new Signal that is fired when the provided action enters the up state. If an action is in the down state and it is unset or rebound, the up event will fire.

    Parameters

    • name: string

      An action name.

    Returns Signal<[event: InputActionEvent]>

    A Signal that can be connected to, to listen for action down events.

  • Register a multiplier on user's set sensitivity

    Parameters

    • sensitivity: number

      Set to 1 for no effect, >1 for increased sensitivty.

    Returns void

  • Hides all mobile buttons that trigger the action name.

    Parameters

    • name: string

      An action name.

    Returns void

  • Unsets all actions who share the same binding as the provided InputAction.

    Parameters

    • action: InputAction

      An InputAction.

    Returns void