private void EyeRaycast()
        {
            // Create a ray that points forwards from the camera.
            Ray        ray = new Ray(m_Camera.position, m_Camera.forward);
            RaycastHit hit;

            // Do the raycast forweards to see if we hit an interactive item
            if (Physics.Raycast(ray, out hit, m_RayLength))
            {
                gazeableObject interactible = hit.collider.GetComponent <gazeableObject>();
                //attempt to get the VRInteractiveItem on the hit object
                m_CurrentGazeable = 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_LastGazeable)
                {
                    interactible.Over();
                }

                // Deactive the last interactive item
                if (interactible != m_LastGazeable)
                {
                    DeactiveateLastInteractible();
                }

                m_LastGazeable = interactible;

                if (interactible)
                {
                    m_Reticle.SetOn(true);
                }
                else
                {
                    m_Reticle.SetOn(false);
                }

                // Something was hit, set at the hit position.
                if (m_Reticle)
                {
                    m_Reticle.SetPosition(hit);
                }
            }
            else
            {
                // Nothing was hit, deactive the last interactive item.
                DeactiveateLastInteractible();
                m_CurrentGazeable = null;
                m_Reticle.SetOn(false);

                // Position the reticle at default distance.
                if (m_Reticle)
                {
                    m_Reticle.SetPosition();
                }
            }
        }
        private void DeactiveateLastInteractible()
        {
            if (m_LastGazeable == null)
            {
                return;
            }

            m_LastGazeable.Out();
            m_LastGazeable = null;
        }
    private bool m_Selected;                                            // Whether the user is looking at the VRInteractiveItem currently.

    private void Awake()
    {
        if (m_InteractiveItem == null)
        {
            m_InteractiveItem = this.GetComponent <gazeableObject>();
        }

        if (thePlayer == null)
        {
            thePlayer         = GameObject.FindObjectOfType <mainPlayer>();
            m_SelectionRadial = thePlayer.GetComponent <gazeTimerVisual>();
        }
    }
예제 #4
0
    private void Awake()
    {
        m_InteractiveItem = this.GetComponent <gazeableObject>();
        m_Renderer        = this.GetComponent <Renderer>();
        tmpLabel          = GetComponentInChildren <TextMeshPro>();
        roomSwitcher      = FindObjectOfType <switchRooms>();
        m_SelectionRadial = FindObjectOfType <gazeTimerVisual>();

        if (m_Renderer)
        {
            m_Renderer.material = m_NormalMaterial;
        }

        setRoom(curRoom);
    }