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.

mobileButtonPrefab: GameObject = ...

The default mobile button prefab.

mobileControlsContainer: GameObject

Container that holds mobile control buttons.

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 Binding from a deserialized action. The returned Binding can be used to update an existing action.

    Parameters

    • action: SerializableAction

      A deserialized action.

    Returns Binding

    A Binding that matches the deserialized action data.

  • Creates a dynamic joystick.

    Alternatively, you can place a DynamicJoystick.prefab in your scene and reference that directly.

    Parameters

    • parent: Transform

      This should be a parent transform that you have positioned in your canvas. The joystick will be instiated as a child at (0,0,0).

    Returns default

    The created DynamicJoystick. DynamicJoystick contains input and dragging properties you can read every frame. DynamicJoystick is an AirshipBehaviour.

  • 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 GameObject

  • 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

    • inputAction: string

      The action name associated with this prompt.

    • objectText: string

      The title above the keybind. This is usually the name of the object.

      Empty string can be used to now show the object text.

    • actionText: string

      The action below the keybind. This is usually something like "Pick up".

    • Optional parent: Transform

      An optional parent Transform that this prompt will live underneath.

    • Optional config: {
          maxRange?: number;
      }

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

      • Optional maxRange?: number

    Returns default

    The created ProximityPrompt.

  • Creates a touch joystick.

    Alternatively, you can place a TouchJoystick.prefab in your scene and reference that directly.

    Note: touch joysticks will not work when the mouse is locked.

    Parameters

    • parent: Transform

      This should be a parent transform that you have positioned in your canvas. The joystick will be instiated as a child at (0,0,0).

    Returns default

    The created TouchJoystick. TouchJoystick contains input and dragging properties you can read every frame. TouchJoystick is an AirshipBehaviour.

  • Deserializes and binds core keybind overrides. These overrides are set when a keybind is updated through the keybind menu.

    Parameters

    • keybinds: {
          Back: undefined | SerializableAction;
          Crouch: undefined | SerializableAction;
          Emote: undefined | SerializableAction;
          Forward: undefined | SerializableAction;
          Interact: undefined | SerializableAction;
          Inventory: undefined | SerializableAction;
          Jump: undefined | SerializableAction;
          Left: undefined | SerializableAction;
          PrimaryAction: undefined | SerializableAction;
          PushToTalk: undefined | SerializableAction;
          Right: undefined | SerializableAction;
          SecondaryAction: undefined | SerializableAction;
          Sprint: undefined | SerializableAction;
      }

      Keybinds parsed from ClientSettings.json.

      • Back: undefined | SerializableAction
      • Crouch: undefined | SerializableAction
      • Emote: undefined | SerializableAction
      • Forward: undefined | SerializableAction
      • Interact: undefined | SerializableAction
      • Inventory: undefined | SerializableAction
      • Jump: undefined | SerializableAction
      • Left: undefined | SerializableAction
      • PrimaryAction: undefined | SerializableAction
      • PushToTalk: undefined | SerializableAction
      • Right: undefined | SerializableAction
      • SecondaryAction: undefined | SerializableAction
      • Sprint: undefined | SerializableAction

    Returns void

  • Unsets a list of core actions. The player will not be able to see these actions in their settings UI while in your game.

    Parameters

    • coreActions: CoreAction[]

      List of actions to unbind and hide

    Returns void

  • 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 the string representation of the provided action's keybind. If the action does not exist, or if called from a mobile context, this returns empty string.

    Parameters

    • actionName: string

    Returns string

    The string representation of the action's binding.

  • Returns a list of all the mobile button action names

    Returns readonly string[]

  • Gets all mobile buttons associated with the given action

    Parameters

    • actionName: string

      The action name

    Returns readonly GameObject[]

    The mobile buttons

  • Gets the mobile camera movement component

    Returns undefined | default

  • Get the mobile touch joystick (static or dynamic based on settings)

    Returns undefined | default | default

  • 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

  • Checks if a core action is enabled.

    Parameters

    • actionName: string

      The name of the action to check

    Returns boolean

    True if the action is enabled, false otherwise

  • 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 sprint toggle based on player's setting.

    Returns boolean

    sprint toggle based on player's setting.

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

    Parameters

    • name: string

      An action name.

    Returns boolean

  • Returns mute toggle based on player's setting.

    Returns boolean

    mute toggle based on player's setting.

  • Observes keybind updates associated with the provided action name. Use the returned function to disconnect from this event.

    Parameters

    • actionName: string

      The name of the action to observe.

    • callback: ((action) => void)

      The callback to invoke with the updated InputAction.

        • (action): void
        • Parameters

          • action: InputAction

          Returns void

    Returns (() => void)

    A disconnect function.

      • (): void
      • Returns void

  • 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.

  • Same as CreateAction (except it won't broadcast over context bridge)

    Parameters

    • name: string
    • binding: Binding
    • Optional config: InputActionConfig
    • isCore: boolean = false

    Returns InputAction

  • Bulk register action

    Parameters

    • actions: InputActionSchema[]

    Returns void

  • Sets the provided action to the down state and fires all active OnDown signals. If the action is already in the down state, active OnDown signals are not fired.

    Parameters

    • name: string

      An action name.

    Returns void

  • Show or hide all mobile controls. Hiding will also clear any Down inputs.

    Parameters

    • visible: boolean

    Returns void

  • Register a multiplier on user's set sensitivity

    Parameters

    • sensitivity: number

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

    Returns void

  • Sets the provided action to the up state and fires all active OnUp signals. If the action is not in the down state, active OnUp signals are not fired.

    Parameters

    • name: string

      An action name.

    Returns void

  • Shows all mobile buttons that trigger the action name.

    Parameters

    • name: string

      An action name.

    Returns void

  • Unregisters an action (removes binding, clears from settings menu)

    Parameters

    • name: string

    Returns void

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

    Parameters

    • action: InputAction

      An InputAction.

    Returns void