/// <summary> /// 获得指定按键是否在这一帧抬起 /// </summary> /// <param name="controllerButton"></param> /// <returns></returns> public bool GetButtonUp(XBoxControllerButton controllerButton) { #if UNITY_METRO && !UNITY_EDITOR return(controllerInput.GetButtonUp((ControllerButton)controllerButton)); #else return(Input.GetButtonUp(TransformButtonId(controllerButton))); #endif }
private string TransformButtonId(XBoxControllerButton controllerButton) { string rs = null; switch (controllerButton) { case XBoxControllerButton.A: rs = "JoystickA"; break; case XBoxControllerButton.B: rs = "JoystickB"; break; case XBoxControllerButton.X: rs = "JoystickX"; break; case XBoxControllerButton.Y: rs = "JoystickY"; break; case XBoxControllerButton.LeftShoulder: rs = "JoystickLB"; break; case XBoxControllerButton.RightShoulder: rs = "JoystickRB"; break; case XBoxControllerButton.LeftThumbstick: rs = "LeftAnalog"; break; case XBoxControllerButton.RightThumbstick: rs = "RightAnalog"; break; case XBoxControllerButton.View: rs = "JoystickView"; break; case XBoxControllerButton.Menu: rs = "JoystickMenu"; break; } return(rs); }