Esempio n. 1
0
        private void OnDisable()
        {
            clearCallbacks();

            m_LastInteractible    = m_CurrentInteractible;
            m_CurrentInteractible = null;
        }
Esempio n. 2
0
        protected override void doRaycast()
        {
            // Show the debug ray if required
            if (ShowDebugRay)
            {
                Debug.DrawRay(CameraT.position, CameraT.forward * DebugRayLength, Color.blue, DebugRayDuration);
            }

            // Create a ray that points forwards from the camera.
            Ray        ray = new Ray(CameraT.position, CameraT.forward);
            RaycastHit hit;

            // Do the raycast forweards to see if we hit an interactive item
            if (Physics.Raycast(ray, out hit, RayLength, ~ExclusionLayers))
            {
                // Something was hit, set at the hit position.
                m_HitPosition = hit.point;
                m_HitAngle    = Quaternion.FromToRotation(Vector3.forward, hit.normal);

                VRInteractiveItem interactible = hit.collider.GetComponent <VRInteractiveItem>(); //attempt to get the VRInteractiveItem on the hit object
                m_CurrentInteractible = interactible;

                // If we hit an interactive item and it's not the same as the last interactive item, then call Over
                if (interactible && interactible != m_LastInteractible)
                {
                    interactible.GazeOver(m_VrInput);
                }

                // Deactive the last interactive item
                if (interactible != m_LastInteractible)
                {
                    deactiveLastInteractible();
                }

                m_LastInteractible = interactible;

                // Something was hit, set at the hit position.
                if (Reticle)
                {
                    Reticle.SetPosition(hit);
                }

                _onRaycastHit(hit);
            }
            else
            {
                // Nothing was hit, deactive the last interactive item.
                deactiveLastInteractible();
                m_CurrentInteractible = null;

                // Position the reticle at default distance.
                if (Reticle)
                {
                    Reticle.SetPosition();
                }
            }
        }