コード例 #1
0
    public void TriggerPressed()
    {
        if (!enabled)
        {
            return;
        }

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

        //I pushed the button, is there somebody I'm looking at who would care about this?
        if (currentlyGazing && gazedObject != null && gazeResponder != null)
        {
            gazeResponder.OnGazeTrigger();
            pressedObject = gazeResponder;

//			if(MergeReticle.instance != null) MergeReticle.instance.OnClickAction ();
        }

        //Inform anybody else who would care about this
        if (OnGaze_InputDown != null)
        {
            OnGaze_InputDown.Invoke();
        }
    }
コード例 #2
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);
    }
コード例 #3
0
    void CheckInput()
    {
        if (isVRMode)
        {
            //Always use gaze input
            TryGazeInput();
        }
        else
        {
            if (currMode == GazeModeEnum.tapOnly)
            {
                TryTapInput();
            }
            else if (currMode == GazeModeEnum.tapFirst)
            {
                if (!TryTapInput())
                {
                    TryGazeInput();
                }
            }
            else if (currMode == GazeModeEnum.gazeFirst)
            {
                if (!TryGazeInput())
                {
                    TryTapInput();
                }
            }
            else if (currMode == GazeModeEnum.gazeOnly || currMode == GazeModeEnum.hoverOnly)
            {
                TryGazeInput();
            }
        }

        if (Input.GetMouseButtonDown(0) && IsValidClick())
        {
            if (currMode != GazeModeEnum.hoverOnly)
            {
                TriggerPressed();
            }
        }

        if (Input.GetMouseButtonUp(0) && IsValidClick())
        {
            if (currMode != GazeModeEnum.hoverOnly)
            {
                TriggerReleased();
                if (isVRMode)
                {
                    currentlyGazing = false;
                    gazedObject     = null;
                    gazeResponder   = null;
                }
            }
        }
    }
コード例 #4
0
    public void TriggerReleased()
    {
        if (!enabled)
        {
            return;
        }

        //I stopped pushing the button, does the guy who would care about this still exist?
        if (pressedObject != null)
        {
            pressedObject.OnGazeTriggerEnd();
            pressedObject = null;
        }

        //Inform anybody else who would care about this
        if (OnGaze_InputUp != null)
        {
            OnGaze_InputUp.Invoke();
        }
    }
コード例 #5
0
    public void TriggerReleased()
    {
        if (!enabled)
        {
            return;
        }
        if (MergeReticle.instance != null)
        {
            MergeReticle.instance.OffClickAction();
        }
        if (pressedObject != null)
        {
            pressedObject.OnGazeTriggerEnd();
            pressedObject = null;
        }

        if (OnGaze_InputUp != null)
        {
            OnGaze_InputUp.Invoke();
        }
    }
コード例 #6
0
    void ResetGaze()
    {
        if (currentlyGazing && gazeResponder != null && gazedObject != null)
        {
            gazeResponder.OnGazeExit();

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

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

        currentlyGazing = false;
        gazedObject     = null;
        gazeResponder   = null;
    }
コード例 #7
0
    public void TriggerPressed()
    {
        if (!enabled)
        {
            return;
        }

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

        if (currentlyGazing && gazedObject != null && gazeResponder != null)
        {
            gazeResponder.OnGazeTrigger();
            pressedObject = gazeResponder;
        }
        if (OnGaze_InputDown != null)
        {
            OnGaze_InputDown.Invoke();
        }
    }
コード例 #8
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;
            }
        }
    }
コード例 #9
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        // do a Physics raycast directly forward from center of the camera.
        // If it hits something in its mask:
        if (Physics.Raycast(gazeCam.transform.position, gazeCam.transform.forward, out hit, 100f, _gazeLayerMask))
        {
            // Check that the object hit is a GazeResponder.
            potential_gr = hit.collider.gameObject.GetComponent <GazeResponder> ();
//			if (!potential_gr) {
//				if
//				potential_gr = hit.collider.gameObject.GetComponentInChildren<ConversationButton> ();
//			}
            // If it is:
            if (potential_gr && !potential_gr.inactive)
            {
                UIManager.instance.Reticle_parent.transform.localScale = Vector3.Slerp(UIManager.instance.Reticle_parent.transform.localScale, new Vector3(1.4f, 1.4f, 1.4f), .3f);
                // If we've been looking at this continuously:
                if (potential_gr == previous_gr)
                {
                    continuous_time += Time.deltaTime;
                    // If we have been looking at this long enough to qualify as a Gaze action:
                    float progressRingFill = (continuous_time / secondsUntilGaze);
                    UIManager.instance.Reticle_inner.GetComponent <Image>().fillAmount = progressRingFill;
                    if (continuous_time >= secondsUntilGaze)
                    {
                        UIManager.instance.Reticle_parent.transform.localScale = Vector3.Slerp(UIManager.instance.Reticle_parent.transform.localScale, new Vector3(1f, 1f, 1f), .3f);
                        Debug.Log("Gaze Triggered on " + hit.collider.gameObject.name);
                        // Notify the GazeResponder and tell it to, uh, respond.
                        UIManager.instance.Reticle_inner.GetComponent <Image>().fillAmount = 0f;
                        continuous_time = 0f;
                        potential_gr.Invoke();
                    }

                    // If we haven't been looking at this continuously:
                }
                else
                {
                    continuous_time = 0f;
                    UIManager.instance.Reticle_inner.GetComponent <Image>().fillAmount = 0f;

                    previous_gr = potential_gr;
//					Debug.Log ("i see a gazresponder " + hit.collider.gameObject.name);
                }
            }
            else
            {
                // If no valid gaze responder was seen
                continuous_time = 0f;
                UIManager.instance.Reticle_inner.GetComponent <Image>().fillAmount = 0f;
                UIManager.instance.Reticle_parent.transform.localScale             = Vector3.Slerp(UIManager.instance.Reticle_parent.transform.localScale, new Vector3(1f, 1f, 1f), .3f);
            }


//			if (hit.collider.gameObject.tag.Equals ("friend")) {
////				reticle.color = Color.green;
//			} else if (hit.collider.gameObject.tag.Equals ("dialogButton")) {
////				reticle.color = Color.cyan;
//			} else {
//				reticle.transform.localScale = Vector3.one;
//			}

            // If it doesn't hit something:
        }
        else
        {
            continuous_time = 0f;
            UIManager.instance.Reticle_inner.GetComponent <Image>().fillAmount = 0f;
            UIManager.instance.Reticle_parent.transform.localScale             = Vector3.Slerp(UIManager.instance.Reticle_parent.transform.localScale, new Vector3(1f, 1f, 1f), .3f);
        }

////		Debug.Log (results.Count);
//		foreach (RaycastResult r in results) {
//			if (r.gameObject.GetComponent<GazeResponder> ()) {
//			} else {
//				Debug.Log ("Not a gaze responder " + r.gameObject.name);
//			}
//		}
    }