Interface into the Input system.
Use this class to read the axes set up in the Input Manager, and to access multi-touch/accelerometer data on mobile devices.
To read an axis use Input.GetAxis with one of the following default axes: "Horizontal" and "Vertical" are mapped to joystick, A, W, S, D and the arrow keys. "Mouse X" and "Mouse Y" are mapped to the mouse delta. "Fire1", "Fire2" "Fire3" are mapped to Ctrl, Alt, Cmd keys and three mouse or joystick buttons. New input axes can be added in the Input Manager.
If you are using input for any kind of movement behaviour use Input.GetAxis. It gives you smoothed and configurable input that can be mapped to keyboard, joystick or mouse. Use Input.GetButton for action like events only. Don't use it for movement, Input.GetAxis will make the script code smaller and simpler.
Note also that the Input flags are not reset until "Update()", so its suggested you make all the Input Calls in the Update Loop.
iOS and Android devices are capable of tracking multiple fingers touching the screen simultaneously. You can access data on the status of each finger touching screen during the last frame by accessing the Input.touches property array.
As a device moves, its accelerometer hardware reports linear acceleration changes along the three primary axes in three-dimensional space. You can use this data to detect both the current orientation of the device (relative to the ground) and any immediate changes to that orientation.
Acceleration along each axis is reported directly by the hardware as G-force values. A value of 1.0 represents a load of about +1g along a given axis while a value of -1.0 represents -1g. If you hold the device upright (with the home button at the bottom) in front of you, the X axis is positive along the right, the Y axis is positive directly up, and the Z axis is positive pointing toward you.
You can read the Input.acceleration property to get the accelerometer reading. You can also use the Input.deviceOrientation property to get a discrete evaluation of the device's orientation in three-dimensional space. Detecting a change in orientation can be useful if you want to create game behaviors when the user rotates the device to hold it differently.
Note that the accelerometer hardware can be polled more than once per frame. To access all accelerometer samples since the last frame, you can read the Input.accelerationEvents property array. This can be useful when reconstructing player motions, feeding acceleration data into a predictor, or implementing other precise motion analysis.
The Unity mobile devices input API is based on Apple's iOS API. It may help to learn more about the native API to better understand Unity's Input API. If you're a registered iOS developer, you can find Apple's input API documentation online.
This property controls if input sensors should be compensated for screen orientation.
Returns default gyroscope.
The current mouse position in pixel coordinates. (Read Only)
Is any key or mouse button currently held down? (Read Only)
Returns true the first frame the user hits any key or mouse button. (Read Only)
Returns the keyboard input entered this frame. (Read Only)
Last measured linear acceleration of a device in three-dimensional space. (Read Only)
Returns list of acceleration measurements which occurred during the last frame. (Read Only) (Allocates temporary variables).
Number of acceleration measurements which occurred during last frame.
Returns list of objects representing status of all touches during last frame. (Read Only) (Allocates temporary variables).
Number of touches. Guaranteed not to change throughout the frame. (Read Only)
Property indicating whether the system handles multiple touches.
Property for accessing device location (handheld devices only). (Read Only)
Property for accessing compass (handheld devices only). (Read Only)
Device physical orientation as reported by OS. (Read Only)
Controls enabling and disabling of IME input composition.
The current IME composition string being typed by the user.
Does the user have an IME keyboard input source selected?
The current text input position used by IMEs to open windows.
Returns the value of the virtual axis identified by axisName.
Returns the value of the virtual axis identified by axisName with no smoothing filtering applied.
Returns true while the virtual button identified by buttonName is held down.
Returns true during the frame the user pressed down the virtual button identified by buttonName.
Returns true the first frame the user releases the virtual button identified by buttonName.
Returns true while the user holds down the key identified by name. Think auto fire.
Returns true during the frame the user starts pressing down the key identified by name.
Returns true during the frame the user releases the key identified by name.
Returns an array of strings describing the connected joysticks.
Returns whether the given mouse button is held down.
Returns true during the frame the user pressed the given mouse button.
Returns true during the frame the user releases the given mouse button.
Resets all input. After ResetInputAxes all axes return to 0 and all buttons return to 0 for one frame.
Returns specific acceleration measurement which occurred during last frame. (Does not allocate temporary variables).
Returns object representing status of a specific touch. (Does not allocate temporary variables).