using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.LowLevel; public class PicoHandDeviceDoEvent : MonoBehaviour { //public HandType handType; CustomPicoHandDevice controller; // Start is called before the first frame update private void Start() { //Sora: 注释 // string hand_name = handType == HandType.HandLeft ? "LeftHand" : "RightHand"; // controller = InputSystem.AddDevice(); // InputSystem.SetDeviceUsage(controller, hand_name); } public void GripOn() { using (StateEvent.From(controller,out var eventptr)) { controller.grabActive.WriteValueFromObjectIntoEvent(eventptr, 1); InputSystem.QueueEvent(eventptr); } } public void GripOff() { using (StateEvent.From(controller, out var eventptr)) { controller.grabActive.WriteValueFromObjectIntoEvent(eventptr, 0); InputSystem.QueueEvent(eventptr); } } }