public bool GetButton(string action) { if (XRDevice.isPresent) { foreach (WebVRControllerInput input in inputMap.inputs) { if (action == input.actionName)// && input.unityInputIsButton) { return(XRInputMaster.ButtonCheck(inputMap.deviceRole, input.usageFeature)); } } } if (!buttonStates.ContainsKey(action)) { return(false); } return(buttonStates[action].pressed); }
public bool GetButtonDown(string action) { // Use Unity Input Manager when XR is enabled and WebVR is not being used (eg: standalone or from within editor). if (UnityEngine.XR.XRDevice.isPresent) { foreach (WebVRControllerInput input in inputMap.inputs) { if (action == input.actionName) // && input.unityInputIsButton) { return(XRInputMaster.ButtonCheck(inputMap.deviceRole, input.usageFeature)); //return Input.GetButtonDown(input.unityInputName); } } } if (GetButton(action) && !GetPastButtonState(action)) { SetPastButtonState(action, true); return(true); } return(false); }
void Update() { if (XRDevice.isPresent) { foreach (WebVRControllerInput input in controller.inputMap.inputs) { bool state = XRInputMaster.ButtonCheck(controller.inputMap.deviceRole, input.usageFeature); if (input.PreviousState != state) { if (state) { input.PreviousState = state; input.OnDown.Invoke(); } else { input.PreviousState = state; input.OnUp.Invoke(); } } } } }