예제 #1
0
        void Start()
        {
            if (instance != null)
            {
                throw new Exception("XRMain already exists");
            }

            instance            = this;
            Time.fixedDeltaTime = Time.timeScale / XRDevice.refreshRate;
            InputDevices.GetDevices(devices);
            List <InputDevice> hands = new List <InputDevice>();

            try
            {
                InputDevices.GetDevicesWithCharacteristics(rightControllerCharacteristics, hands);
                if (hands.Count > 0)
                {
                    rightControllerDevice        = hands[0];
                    rightControllerInput         = rightHand.gameObject.AddComponent <Controller>();
                    controllers[handTypes.right] = rightControllerInput;
                    rightControllerInput.device  = rightControllerDevice;
                }
            }
            catch { }

            try
            {
                InputDevices.GetDevicesWithCharacteristics(leftControllerCharacteristics, hands);
                if (hands.Count > 0)
                {
                    leftControllerDevice        = hands[0];
                    leftControllerInput         = leftHand.gameObject.AddComponent <Controller>();
                    controllers[handTypes.left] = leftControllerInput;
                    leftControllerInput.device  = leftControllerDevice;
                }
            }
            catch { }
        }
예제 #2
0
 private void OnDestroy()
 {
     instance = null;
 }