Class AbstractInputSystem
Represents a base class to abstract input system actions.
This class automatically detects whether the old input system (UnityEngine.Input)
or the new input system (UnityEngine.InputSystem) is available, and delegates
input calls accordingly.
Inheritance
Inherited Members
Namespace: TriLibCore.Samples
Assembly: Assembly-CSharp.dll
Syntax
public class AbstractInputSystem : MonoBehaviour
Methods
GetAxis(string)
Retrieves the value of the specified axis (e.g., "Horizontal", "Vertical", "Mouse X", "Mouse Y")
using either the legacy or the new input system.
On mobile devices, touch movement is used to simulate mouse axis behavior.
Declaration
protected float GetAxis(string axisName)
Parameters
Type | Name | Description |
---|---|---|
string | axisName | Name of the axis to retrieve. Common examples: "Horizontal", "Vertical", "Mouse X", "Mouse Y". |
Returns
Type | Description |
---|---|
float | The current axis value, generally in the range [-1, 1], though mouse deltas and touch movements may produce different ranges. Defaults to 0 if unsupported. |
GetKey(KeyCode)
Determines if a given keyboard key is currently being pressed, using either the new input system or the legacy system.
Declaration
protected bool GetKey(KeyCode keyCode)
Parameters
Type | Name | Description |
---|---|---|
KeyCode | keyCode | The Unity KeyCode to check (e.g., KeyCode.LeftAlt). |
Returns
Type | Description |
---|---|
bool | True if the specified key is pressed; otherwise, false. |
GetMouseButton(int)
Gets whether a specified mouse button (or equivalent gesture on mobile) is currently pressed.
Returns true when the requested button is down in the current frame.
Declaration
protected bool GetMouseButton(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The mouse button index:
|
Returns
Type | Description |
---|---|
bool | True if the specified mouse button (or gesture) is currently pressed; otherwise, false. |
GetMouseButtonDown(int)
Gets whether a specified mouse button was pressed down this frame (or equivalent gesture on mobile).
Returns true only during the frame the user starts pressing the button/gesture.
Declaration
protected bool GetMouseButtonDown(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The mouse button index:
|
Returns
Type | Description |
---|---|
bool | True if the specified mouse button (or gesture) was pressed down during this frame; otherwise, false. |
GetMouseScrollDelta()
Retrieves the current scroll delta on desktop or simulates it via pinch gestures on mobile.
On mobile devices with multi-touch, the difference in touch distances is used to emulate a scroll wheel.
Declaration
protected Vector2 GetMouseScrollDelta()
Returns
Type | Description |
---|---|
Vector2 | A UnityEngine.Vector2 representing the scroll delta. |