示例#1
0
        private static VRInputDevice CreateVRInputDevice(GameObject go, XRNodeState state)
        {
            InputDevice device = InputDevices.GetDeviceAtXRNode(state.nodeType);

            if (device != null)
            {
                VRInputDevice vrInputDevice = go.AddComponent <VRInputDevice>();
                vrInputDevice.Device = device;
                return(vrInputDevice);
            }

            return(null);
        }
示例#2
0
        protected override void AwakeOverride()
        {
            base.AwakeOverride();
            m_nullDevice         = gameObject.AddComponent <VRInputDevice>();
            m_nullDevice.enabled = false;

            m_leftHand  = m_nullDevice;
            m_rightHand = m_nullDevice;

            IOC.RegisterFallback <IVRTracker>(this);

            InputTracking.trackingAcquired += OnTrackingAquired;
            InputTracking.trackingLost     += OnTrackingLost;
        }
示例#3
0
        private void OnTrackingAquired(XRNodeState state)
        {
            Debug.Log("Tracking Aquired " + state.nodeType);

            if (state.nodeType == XRNode.LeftHand)
            {
                if (m_leftHand == m_nullDevice)
                {
                    m_leftHand = CreateVRInputDevice(gameObject, state);
                    RaiseTrackingAcquired(m_leftHand);
                }
            }
            else if (state.nodeType == XRNode.RightHand)
            {
                if (m_rightHand == m_nullDevice)
                {
                    m_rightHand = CreateVRInputDevice(gameObject, state);
                    RaiseTrackingAcquired(m_rightHand);
                }
            }
        }
示例#4
0
 private void OnTrackingLost(XRNode nodeType)
 {
     if (nodeType == XRNode.LeftHand)
     {
         if (m_leftHand != m_nullDevice)
         {
             RaiseTrackingLost(m_leftHand);
             Destroy(m_leftHand);
             m_leftHand = m_nullDevice;
         }
     }
     else if (nodeType == XRNode.RightHand)
     {
         if (m_rightHand != m_nullDevice)
         {
             RaiseTrackingLost(m_rightHand);
             Destroy(m_rightHand);
             m_rightHand = m_nullDevice;
         }
     }
 }