public float GetAxis(string action) { for (var i = 0; i < inputMap.inputs.Count; i++) { WebVRControllerInput input = inputMap.inputs[i]; if (action == input.actionName) { if (UnityEngine.XR.XRDevice.isPresent && !input.unityInputIsButton) { return(Input.GetAxis(input.unityInputName)); } else { if (input.gamepadIsButton) { if (!buttonStates.ContainsKey(action)) { return(0); } return(buttonStates[action].value); } else { return(axes[i]); } } } } return(0); }
public float GetAxis(string action) { for (var i = 0; i < inputMap.inputs.Count; i++) { WebVRControllerInput input = inputMap.inputs[i]; if (action == input.actionName) { if (UnityEngine.XR.XRDevice.isPresent && !input.unityInputIsButton) { return(Input.GetAxis(input.unityInputName)); } else { if (input.gamepadIsButton) { if (!buttonStates.ContainsKey(action)) { return(0); } return(buttonStates[action].value); } else { // Previously this was: return axes[i], which is nuts because you have to // organize the input axes at the top of your list for it to work properly return(axes[input.gamepadId]); } } } } return(0); }