Пример #1
0
    bool CheckRay(Ray ray, bool isTapTp = false)
    {
        if (Physics.Raycast(ray, out hit, 100000f, lMask))
        {
            if (isTapTp)
            {
                if (tapInputIdentifier != "" && hit.transform.tag != tapInputIdentifier)
                {
                    return(false);
                }
            }
            if (hit.transform.gameObject != gazedObject)
            {
                if (gazeResponder != null)
                {
                    gazeResponder.OnGazeExit();

                    if (MergeReticle.instance != null)
                    {
                        MergeReticle.instance.OffHoverAction();
                    }

                    if (OnGaze_End != null)
                    {
                        OnGaze_End.Invoke();
                    }
                }
                currentlyGazing = false;
                gazedObject     = hit.transform.gameObject;
                gazeResponder   = hit.transform.GetComponent <GazeResponder>();
            }

            //We were  NOT previously looking at something last tick, so lets have it do stuff
            //I must be looking at something new, look at the new thing.
            if (!currentlyGazing && gazedObject != null && gazeResponder != null)
            {
                gazeResponder.OnGazeEnter();

                if (MergeReticle.instance != null)
                {
                    MergeReticle.instance.OnHoverAction();
                }

                if (OnGaze_Start != null)
                {
                    OnGaze_Start.Invoke();
                }
                currentlyGazing = true;
            }
            return(true);
        }
        else        // if (!isTapTp)
        {
            ResetGaze();
        }
        return(false);
    }
Пример #2
0
    void Update()
    {
        Ray ray = new Ray();

        //Set up the ray to aim either at the screen position for tapping in Mono screen or for forward gaze direction for dual screen
        if (isMonoScreenMode)
        {
            ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        }
        else
        {
            ray.origin    = this.transform.position;
            ray.direction = this.transform.forward;
        }

        if (Physics.Raycast(ray, out hit, 100000f, lMask))
        {
            Debug.DrawRay(ray.origin, ray.direction);

            //The thing we are looking at isnt the same guy!!
            if (hit.transform.gameObject != gazedObject)
            {
                //Stop looking at the old guy! Tell him to go away.
                if (gazeResponder != null)
                {
//					Debug.Log("Gaze End");
                    gazeResponder.OnGazeExit();

                    if (OnGaze_End != null)
                    {
                        OnGaze_End.Invoke();
                    }
                }

//				Debug.Log("Cleaned CurGaze");
                //Clean up for the new guy
                currentlyGazing = false;
                gazedObject     = hit.transform.gameObject;
                gazeResponder   = hit.transform.GetComponent <GazeResponder>();
            }

            //We were  NOT previously looking at something last tick, so lets have it do stuff
            //I must be looking at something new, look at the new thing.
            if (!currentlyGazing && gazedObject != null && gazeResponder != null)
            {
//				Debug.Log("Gaze Start");
                gazeResponder.OnGazeEnter();

                if (OnGaze_Start != null)
                {
                    OnGaze_Start.Invoke();
                }

//				Debug.Log("Set CurGaze: " + gazedObject.name);
                currentlyGazing = true;
            }
        }
        else
        {
//			Debug.Log("Gaze End");
            //We aren't looking at anything at all. Clean up and stop looking at the previous guy
            //We were previously looking at something last tick, so lets have it do stuff
            if (currentlyGazing && gazeResponder != null && gazedObject != null)
            {
                gazeResponder.OnGazeExit();

                if (OnGaze_End != null)
                {
                    OnGaze_End.Invoke();
                }
            }

            currentlyGazing = false;
            gazedObject     = null;
            gazeResponder   = null;
        }

        if (Input.GetMouseButtonDown(0))
        {
//			Debug.Log("TAP");
            TriggerPressed();
        }

        if (Input.GetMouseButtonUp(0))
        {
//			Debug.Log("END TAP");
            TriggerReleased();

            if (isMonoScreenMode)
            {
//				Debug.Log("Is mono screen mode? " + isMonoScreenMode);
                currentlyGazing = false;
                gazedObject     = null;
                gazeResponder   = null;
            }
        }
    }
Пример #3
0
    void Update()
    {
        Ray ray = new Ray();

        //Set up the ray to aim either at the screen position for tapping in Mono screen or for forward gaze direction for dual screen
        if (isFullScreen)
        {
            if (isFullScreenCenterRayAllTime)
            {
                ray.origin    = this.transform.position;
                ray.direction = this.transform.forward;
            }
            else
            {
                if (Input.GetMouseButtonDown(0))
                {
                    ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    if (isBothClickMode)
                    {
                        Debug.LogWarning("In Click");
                        RaycastHit hitB;
                        if (Physics.Raycast(new Ray(transform.position, transform.forward), out hitB, 100000f, lMask))
                        {
                            Debug.LogWarning("Hit");
                            if (hitB.transform.GetComponent <IntroGazeResponder> () != null)
                            {
                                Debug.LogWarning("Have Receiver");
                                hitB.transform.GetComponent <IntroGazeResponder> ().OnGazeEnter();
                                hitB.transform.GetComponent <IntroGazeResponder> ().OnGazeTrigger();
                            }
                        }
                    }
                }
                else
                {
                    return;
                }
            }
        }
        else
        {
            ray.origin    = this.transform.position;
            ray.direction = this.transform.forward;
        }

        if (Physics.Raycast(ray, out hit, 100000f, lMask))
        {
            Debug.DrawRay(ray.origin, ray.direction);

            if (hit.transform.gameObject != gazedObject)
            {
                if (gazeResponder != null)
                {
                    gazeResponder.OnGazeExit();

                    if (OnGaze_End != null)
                    {
                        OnGaze_End.Invoke();
                    }
                }

                currentlyGazing = false;
                gazedObject     = hit.transform.gameObject;
                gazeResponder   = hit.transform.GetComponent <IntroGazeResponder>();
            }

            if (!currentlyGazing && gazedObject != null && gazeResponder != null)
            {
//				Debug.Log("Gaze Start");
                gazeResponder.OnGazeEnter();

                if (OnGaze_Start != null)
                {
                    OnGaze_Start.Invoke();
                }

//				Debug.Log("Set CurGaze: " + gazedObject.name);
                currentlyGazing = true;
            }
        }
        else
        {
//			Debug.Log("Gaze End");
            //We aren't looking at anything at all. Clean up and stop looking at the previous guy
            //We were previously looking at something last tick, so lets have it do stuff
            if (currentlyGazing && gazeResponder != null && gazedObject != null)
            {
                gazeResponder.OnGazeExit();

                if (OnGaze_End != null)
                {
                    OnGaze_End.Invoke();
                }
            }

            currentlyGazing = false;
            gazedObject     = null;
            gazeResponder   = null;
        }

        if (Input.GetMouseButtonDown(0))
        {
//			Debug.Log("TAP");
            TriggerPressed();
        }

        if (Input.GetMouseButtonUp(0))
        {
//			Debug.Log("END TAP");
            TriggerReleased();

            if (isFullScreen)
            {
                currentlyGazing = false;
                gazedObject     = null;
                gazeResponder   = null;
            }
        }
    }