Input
public static abstract sealed class Input Allows querying of player button presses and other inputs.
Properties
| Name | Type | Description |
|---|---|---|
ControllerCount static | Int32 | How many controllers are active right now? |
EnableVirtualCursor static | Boolean | Whether or not the Virtual Cursor should show when using a controller. Disable this to control the cursor manually. |
UsingController static | Boolean | Was the last button pressed a game controller button? |
EscapePressed static | Boolean | True if escape was pressed |
ActionNames static | IEnumerable<String> | Names of all actions from the current game's input settings. |
Suppressed static | Boolean | If the input is suppressed then everything will act like there is no input |
VR static | VRInput | Virtual Reality specific input data. |
MouseDelta static | Vector2 | Movement delta from the mouse. |
MouseWheel static | Vector2 | The state of the mouse wheel. |
MouseCursorVisible static | Boolean | True if the mouse cursor is visible (using UI etc) |
AnalogLook static | Angles | Analog look value from the default input device. This is scaled by Preferences.Sensitivity - so you don't need to scale it afterwards. |
AnalogMove static | Vector3 | Analog move value from the default input device. |
MotionData static | InputMotionData | Current state of the current input device's motion sensor(s) if supported. This is only supported on: Dualshock 4+, Switch Controllers, Steam Controller, Steam Deck. |
Methods
static Single GetAnalog(InputAnalog analog) An analog input, when fetched, is between -1 and 1 (0 being default)
static IDisposable PlayerScope(Int32 index) Push a specific player scope to be active
static Boolean Down(String action, Boolean complainOnMissing = True) Action is currently pressed down
static Boolean Pressed(String action) Action wasn't pressed but now it is
static Boolean Released(String action) Action was pressed but now it isn't
static Void SetAction(String action, Boolean down) static Void Clear(String action) Remove this action, so it's no longer being pressed.
action static Void ClearActions() Clears the current input actions, so that none of them are active.
static Void ReleaseActions() Clears the current input actions, so that none of them are active. Unlike ClearActions this will unpress the buttons, so they won't be active again until they're pressed again.
static Void ReleaseAction(String name) Releases the action, and it won't be active again until it's pressed again.
static IEnumerable<InputAction> GetActions() Copies all input actions to be used publicly
static String GetGroupName(String action) Finds the GroupName of the given action.
action — Action name to find the group name of. static String GetButtonOrigin(String name, Boolean ignoreController = False) Returns the name of a key bound to this InputAction For example: Input.GetButtonOrigin( "Undo" ) could return SPACE if using keyboard or A Button when using a controller.
static Texture GetGlyph(String name, InputGlyphSize size = 0, Boolean outline = False) Get a glyph texture from the controller bound to the action. If no binding is found will return an 'UNBOUND' glyph.
static Texture GetGlyph(String name, InputGlyphSize size = 0, GlyphStyle style = null) static Texture GetGlyph(InputAnalog analog, InputGlyphSize size = 0, Boolean outline = False) Get a glyph texture from an analog input on a controller.
static String GetButtonOrigin(InputAnalog analog) Returns the name of the analog axis bound to this InputAnalog. For example: Input.GetButtonOrigin( InputAnalog.Move ) could return Left Joystick
static Void TriggerHaptics(Single leftMotor, Single rightMotor, Single leftTrigger = 0, Single rightTrigger = 0, Int32 duration = 500) Trigger a haptic event on supported controllers including Xbox trigger impulse rumble.
leftMotor — The speed of the left motor, between 0.0 and 1.0. rightMotor — The speed of the right motor, between 0.0 and 1.0. leftTrigger — (Xbox One controller only) The speed of the left trigger motor, between 0.0 and 1.0. rightTrigger — (Xbox One controller only) The speed of the right trigger motor, between 0.0 and 1.0. duration — How long (in milliseconds) should we apply this for? static Void TriggerHaptics(HapticEffect pattern, Single lengthScale = 1, Single frequencyScale = 1, Single amplitudeScale = 1) Trigger haptics based on a predefined HapticEffect. All HapticEffects are normalized (start at 0, peak at 1).
pattern — The pattern to use lengthScale — The amount to scale the pattern's length by. frequencyScale — The amount to scale the pattern's frequency by. amplitudeScale — The amount to scale the pattern's amplitude by. static Void TriggerHaptics(HapticEffect pattern, Single frequencyScale, Single amplitudeScale) Trigger haptics based on a predefined HapticEffect. All HapticEffects are normalized (start at 0, peak at 1).
pattern — The pattern to use frequencyScale — The amount to scale the pattern's frequency by. amplitudeScale — The amount to scale the pattern's amplitude by. static Void StopAllHaptics() Stop all vibration events on the current controller.