Input
- 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.GetJoystickNames 获取控制杆名称列表
static function GetJoystickNames () : string[]
Description描述
Returns an array of stings describing the connected joysticks.
返回一个用来描述已连接的控制杆的字符串集合。
This can be useful in user input configuration screens - this way, instead of showing labels like "Joystick 1", you can show more meaningful names like "Logitech WingMan". To read values from different joysticks, you need to assign respective axes for the number of joysticks you want to support in the input manager.
它可以用在用户输入设置界面 --这样,你就可以把显示的标签"Joystick 1"换成意义更明确的名字像"Logitech WingMan",读取不同控制器的值,你需要分别为各个控制器的数字指定指方向轴如果你想将其使用在输入设置中。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void Update() {
int i = 0;
while (i < 4) {
if (Mathf.Abs(Input.GetAxis("Joy" + i + "X")) > 0.2F || Mathf.Abs(Input.GetAxis("Joy" + i + "Y")) > 0.2F)
Debug.Log(Input.GetJoystickNames()[i] + " is moved");
i++;
}
}
}
// Prints a joystick name if movement is detected.
//如果检测到移动就输出一个控制杆名称
function Update () {
// requires you to set up axes "Joy0X" - "Joy3X" and "Joy0Y" - "Joy3Y" in the Input Manger
//你需要在输入管理器中设置方向轴"Joy0X" - "Joy3X" 和 "Joy0Y" - "Joy3Y"
for (var i : int = 0; i < 4; i++) {
if (Mathf.Abs(Input.GetAxis("Joy"+i+"X")) > 0.2
|| Mathf.Abs(Input.GetAxis("Joy"+i+"Y")) > 0.2)
Debug.Log (Input.GetJoystickNames()[i]+" is moved");
}
}
最后修改:2011年3月12日 Saturday 21:09