- accelerationEventCount
- accelerationEvents
- acceleration
- anyKeyDown
- anyKey
- compositionCursorPos
- compositionString
- deviceOrientation
- eatKeyPressOnTextFieldFocus
- GetAccelerationEvent
- GetAxisRaw
- GetAxis
- GetButtonDown
- GetButtonUp
- GetButton
- GetJoystickNames
- GetKeyDown
- GetKeyUp
- GetKey
- GetMouseButtonDown
- GetMouseButtonUp
- GetMouseButton
- GetPosition
- GetRotation
- GetTouch
- gyro
- imeCompositionMode
- inputString
- isGyroAvailable
- mousePosition
- multiTouchEnabled
- ResetInputAxes
- touchCount
- touches
Input 输入
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.
想要读取轴向使用Input.GetAxis方法获取下列默认轴: "Horizontal" 和"Vertical" 映射于控制杆、A、W、S、D和箭头键(方向键)。 "Mouse X" 和"Mouse Y" 映射于鼠标,"Fire1", "Fire2" "Fire3"映射于键盘的Ctrl、Alt、Cmd键和鼠标中键或控制器的按钮。新的输入设置可以使用输入管理器来添加。
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.
如果你使用Input制作某种运动行为可以使用Input.GetAxis方法,它能够返回来自键盘、控制器或鼠标平缓并且可以设置的输入结果。使用Input.GetButton方法只用于像事件之类的动作。不要将它用于移动动作。Input.GetAxis方法可以使脚本代码更简洁。
Note also that the Input flags are not reset until "Update()", so its suggested you make all the Input Calls in the Update Loop.
注意:每次输入在"Update()"之前不会再更新,所以建议你将所有的输入调用都写在Update方法中。(Update循环中)
Mobile Devices:
移动设备:
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.
iOS和Android设备能够支持多点触控。你可以通过Input.touches属性集合访问在最近一帧中触摸在屏幕上的每一根手指的状态数据。
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.
硬件沿着某感应一轴加速就会立即返回重力值。如果值为1.0代表沿着给定轴的方向+1g的重力加速度,如果值为-1.0代表-1g的重力加速度。如果你保持设备垂直(主页键在下方)在你正前方,那么X轴就是指向你右侧的方向,Y轴指向正上方,Z轴就是你所面向的方向。
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.
你可以读取Input.acceleration属性获得设备的加速度信息。你也可以使用Input.deviceOrientation属性获取设备在三维空间中的方位偏移。检测方位变化在你想要制作游戏行为中会非常有用,当用户转动设备或拿着设备时它是不同的。
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.
注意:速度感应装置在每一帧中能够轮询多次,想访问上一帧的所有速度样本你可以读取Input.accelerationEvents属性集合。这在重组玩家动作中会非常有用。例如将加速数据放入一个预测器中或者实现其他一些精确的动作捕捉。
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. You can find Apple's input API documentation here:
Unity移动设备输入API是以苹果的iOS API为基础。学习一些原生API更有助于理解Unity的Input API。你可以查找苹果的Input API文档:
•Programming Guide: Event Handling (Apple iPhone SDK documentation)
•UITouch Class Reference (Apple iPhone SDK documentation)
NOTE: above links reference your locally installed iOS SDK Reference Documentation and will contain native ObjectiveC code. It is not necessary to understand these documents for using Unity iOS, but may be helpful to some!
注意:以上链接参考你本地安装的iOS SDK参考文档将包含ObjectiveC代码。你没有必要去弄明白这些文档怎么用于UnityiOS,但是能理解点更好。
Class Variables类变量
-
Returns a boolean value that indicates whether a gyroscope is available on the device.
返回布尔值,陀螺仪在设备上是否可用。 -
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).
在第一帧用户按下某一按键或鼠标按钮,返回true(只读)
-
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 (Read Only).
触摸的数量(只读)。 -
Property indicating whether keypresses are eaten by a textinput if it has focus (default true).
该属性表示,如果具有焦点,是否通过文本输入框接收按键(默认为真)。 -
Property indicating whether the system handles multiple touches.
此属性表明此系统是否支持多点触控。 -
Device physical orientation as reported by OS (Read Only).
操作系统所报告的物理设备的方位信息(只读) -
Controls enabling and disabling of IME input composition.
控制IME输入组合的启用和禁用。 -
The current IME composition string being typed by the user.
当前用户正在输入的IME组合字符串。 -
The current text input position used by IMEs to open windows.
当前文本输入位置,使用于IME来打开窗口。
Class Functions类函数
-
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.
根据按钮名称返回true当对应的虚拟按钮被按住时。 -
Returns true during the frame the user pressed down the virtual button identified by buttonName.
在给定名称的虚拟按钮被按下的那一帧返回true。 -
Returns true the first frame the user releases the virtual button identified by buttonName.
在用户释放指定名称的虚拟按钮时返回true。 -
Returns true while the user holds down the key identified by name. Think auto fire.
当通过名称指定的按键被用户按住时返回true。想想自动开火。 -
Returns true during the frame the user starts pressing down the key identified by name.
当用户按下指定名称的按键时的那一帧返回true。 -
Returns true during the frame the user releases the key identified by name.
在用户释放给定名字的按键的那一帧返回true。 -
Returns an array of stings describing the connected joysticks.
返回一个用来描述已连接的控制杆的字符串集合。 -
Returns whether the given mouse button is held down.
当指定的鼠标按钮被按下时返回true -
Returns true during the frame the user pressed the given mouse button.
在用户按下指定鼠标按键的那一帧返回true。 -
Returns true during the frame the user releases the given mouse button.
在用户释放指定鼠标按键的那一帧返回true。 -
Resets all input. After ResetInputAxes all axes return to 0 and all buttons return to 0 for one frame.
在一帧中重置所有的输入,重置输入指令之后所有的方向轴都被设置为0并且所有的按键都被设置为0。 -
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).
返回一个存放触摸信息的对象(不允许分配临时变量)。