示例#1
0
        void Update()
        {
            if (this.actor_ == null)
            {
                return;
            }

            float angle    = GetAngle(this.actor_, this.Target);
            float maxAngle = Mathf.Max(this.MaxAngleMinimum, this.MaxAngleBase - this.MaxAngleDistanceCorrection * (this.Target.position - this.actor_.position).magnitude);

            bool isFocused = angle <= maxAngle;

            if (isFocused && this.gazer_ == null)
            {
                this.gazer_ = this.Gazeable.StartGazer();
            }

            if (this.gazer_ != null && !isFocused)
            {
                this.gazer_.Dispose();
                this.gazer_ = null;
            }

#if UNITY_EDITOR
            DebugInfo.Angle    = angle;
            DebugInfo.MaxAngle = maxAngle;
#endif
        }
示例#2
0
        void Update()
        {
            var cam = this.GazeCamera == null ? Camera.main : this.GazeCamera;

            if (cam == null || this.Gazeable == null || this.Collider == null)
            {
                return;
            }

            Ray        gazeRay = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.0f));
            RaycastHit raycastHit;
            bool       hit = this.Collider.Raycast(gazeRay, out raycastHit, this.MaxDistance);

            // Just started gazing?
            if (hit && this.gazer_ == null)
            {
                this.gazer_ = this.Gazeable.StartGazer();
            }

            // Just ended our gaze?
            if (this.gazer_ != null && !hit)
            {
                this.gazer_.Dispose();
                this.gazer_ = null;
            }
        }
示例#3
0
 private void OnDisable()
 {
     if (this.gazer_ != null)
     {
         this.gazer_.Dispose();
         this.gazer_ = null;
     }
 }
示例#4
0
        void Update()
        {
            this.focusPercentage_ = GetFocusPercentage(this.actor_, this.target);

#if UNITY_EDITOR
            this.DebugInfo.FocusPercentage = this.focusPercentage_;
#endif

            bool isFocused = focusPercentage_ >= minFocusLevel;

            if (isFocused && this.gazer_ == null)
            {
                this.gazer_ = this.gazeable.StartGazer();
            }

            if (this.gazer_ != null && !isFocused)
            {
                this.gazer_.Dispose();
                this.gazer_ = null;
            }
        }
示例#5
0
        void Update()
        {
            var cam = this.RayCamera == null ? Camera.main : this.RayCamera;

            if (cam == null || this.Gazeable == null || this.RaycastReceiver == null)
            {
                return;
            }

            bool hit = RaycastReceiver.Raycast(new Vector2(0.5f, 0.5f), cam);

            // Just started gazing?
            if (hit && this.gazer_ == null)
            {
                this.gazer_ = this.Gazeable.StartGazer();
            }

            // Just ended our gaze?
            if (this.gazer_ != null && !hit)
            {
                this.gazer_.Dispose();
                this.gazer_ = null;
            }
        }