InputDevice leftHandController;
InputDevice rightHandController;
void Start()
{
leftHandController = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
rightHandController = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
GetAll();
}
public List<InputDevice> GetAll()
{
List<InputDevice> deviceList = new List<InputDevice>();
//实际为传入list引用获取的InputDevice全部放在list中
InputDevices.GetDevices(deviceList);
return deviceList;
}
//扳机键
public void DownTrigger()
{
bool isDown; //记录是否按下
if (rightHandController.TryGetFeatureValue(CommonUsages.triggerButton, out isDown) && isDown)
{
Debug.Log("Trigger");
//xxxxx 处理逻辑
}
}
//A键
public void DownA()
{
bool isDown; //记录是否按下
if (rightHandController.TryGetFeatureValue(CommonUsages.primaryButton, out isDown) && isDown)
{
Debug.Log(3);
//xxxxx 处理逻辑
}
}