using System.Collections.Generic; using UnityEngine; using UnityEngine.XR; namespace UnityXR { public class HandPresence : MonoBehaviour { private InputDevice _targetDevice; // Start is called before the first frame update void Start() { List devices = new List(); InputDeviceCharacteristics rightControllerCharacteristics = InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller; if (devices.Count > 0) { _targetDevice = devices[0]; } } // Update is called once per frame void Update() { ; if (_targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonValue) && primaryButtonValue) { Debug.Log("Pressing primary button"); } if (_targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue) && triggerValue > 0.1f) { Debug.Log("Trigger pressed " + triggerValue); } if (_targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) && primary2DAxisValue != Vector2.zero) { Debug.Log("primary2DAxis pressed " + triggerValue); } } } }