static bool GetController(bool rightHand, out XRControllerWithRumble rumbleController) { bool valid = false; rumbleController = null; var controller = rightHand ? XRControllerWithRumble.rightHand : XRControllerWithRumble.leftHand; if (controller != null && controller is XRControllerWithRumble rc) { rumbleController = rc; valid = true; } // todo test // InputAction hapticAction = rightHand ? rightHaptic : leftHaptic; // if (hapticAction?.activeControl?.device is XRControllerWithRumble rc) { // rumbleController = rc; // valid = true; // } return(valid); }
void Update() { XRControllerWithRumble leftHandController = XRController.leftHand as XRControllerWithRumble; leftHapticDetected.color = (leftHandController != null) ? Color.red : Color.white; if (leftHandController != null) { leftHandController.SetIntensity(1f); leftTryingToRumble.color = (m_LeftHandRumbling ? Color.red : Color.white); } XRControllerWithRumble rightHandController = XRController.rightHand as XRControllerWithRumble; rightHapticDetected.color = (rightHandController != null) ? Color.red : Color.white; if (rightHandController != null) { rightHandController.SetIntensity(1f); rightTryingToRumble.color = !m_LeftHandRumbling ? Color.red : Color.white; } UpdateTimer(); }