예제 #1
0
        /// <summary>
        /// 刷新
        /// </summary>
        internal void OnRefresh()
        {
            if (IsOpenRay)
            {
                if (GlobalTools.IsPointerOverUGUI())
                {
                    RaycastHiting(GetCurrentUGUI());
                }
                else
                {
                    _ray = RayCamera.ScreenPointToRay(Main.m_Input.MousePosition);
                    if (Physics.Raycast(_ray, out _hit, 100, ActivatedLayer))
                    {
                        HitPoint = _hit.point;
                        RaycastHiting(_hit.transform.gameObject);
                    }
                    else
                    {
                        RaycastHiting(null);
                    }
                }

                Vector2 pos = Main.m_Input.MousePosition.ScreenToUGUIPosition(null, RayHitImageType);
                RaycastHitBGFlow(pos);
                RayEvent(Target, HitPoint, pos);
            }
        }
예제 #2
0
        /// <summary>
        /// 刷新
        /// </summary>
        public void Refresh()
        {
            if (IsOpenRay)
            {
                if (GlobalTools.IsPointerOverUGUI())
                {
                    RaycastHiting(GetCurrentUGUI());
                }
                else
                {
                    _ray = RayCamera.ScreenPointToRay(Main.m_Input.MousePosition);
                    if (Physics.Raycast(_ray, out _hit, 100, ActivatedLayer))
                    {
                        HitPoint = _hit.point;
                        RaycastHiting(_hit.transform.gameObject);
                    }
                    else
                    {
                        RaycastHiting(null);
                    }
                }

                RaycastHitImageFlow();
            }
        }
예제 #3
0
        private void Control()
        {
            if (!CanControl)
            {
                return;
            }

            if (!IsCanOnUGUI && GlobalTools.IsPointerOverUGUI())
            {
                return;
            }

            if (Main.m_Input.GetButton(InputButtonType.MouseRight))
            {
                X += Main.m_Input.GetAxis(InputAxisType.MouseX) * XSpeed * _factor;
                Y -= Main.m_Input.GetAxis(InputAxisType.MouseY) * YSpeed * _factor;
            }
            if (Main.m_Input.GetAxisRaw(InputAxisType.MouseScrollWheel) != 0)
            {
                Distance -= Main.m_Input.GetAxis(InputAxisType.MouseScrollWheel) * MSpeed * _factor;

                if (AllowOverstepDistance)
                {
                    if (Distance <= MinDistance || Distance >= MaxDistance)
                    {
                        Target.transform.Translate(transform.forward * Main.m_Input.GetAxis(InputAxisType.MouseScrollWheel));
                    }
                }
            }
        }
예제 #4
0
        private void OnMouseDrag()
        {
            if (IsCanDrag)
            {
                if (GlobalTools.IsPointerOverUGUI())
                {
                    return;
                }

                Vector3 mousePoint  = Main.m_Input.MousePosition;
                Vector3 screenPoint = Main.m_Controller.MainCamera.WorldToScreenPoint(transform.position);
                mousePoint.z       = screenPoint.z;
                transform.position = Main.m_Controller.MainCamera.ScreenToWorldPoint(mousePoint + _offset);

                if (!_isDraging)
                {
                    _isDraging = true;
                    BeginDragEvent.Invoke();
                }
                else
                {
                    DragingEvent.Invoke();
                }
            }
        }
예제 #5
0
        private void Control()
        {
            if (!CanControl)
            {
                return;
            }

            if (!IsCanOnUGUI && GlobalTools.IsPointerOverUGUI())
            {
                return;
            }

            if (Main.m_Input.GetButton("MouseRight"))
            {
                //记录鼠标横向移动量
                X += Main.m_Input.GetAxis("MouseX") * XSpeed * _factor;
                //记录鼠标纵向移动量
                Y -= Main.m_Input.GetAxis("MouseY") * YSpeed * _factor;
            }
            if (Main.m_Input.GetAxis("MouseScrollWheel") != 0)
            {
                //鼠标滚轮缩放视角距离
                Distance -= Main.m_Input.GetAxis("MouseScrollWheel") * MSpeed * Time.deltaTime;

                if (Distance <= MinDistance)
                {
                    Target.transform.Translate(transform.forward * Main.m_Input.GetAxis("MouseScrollWheel"));
                }
            }
        }
예제 #6
0
        private void Control()
        {
            if (_isKeepTrack)
            {
                if (_trackTarget)
                {
                    Target.transform.position = _trackTarget.position;
                }
                else
                {
                    _isKeepTrack = false;
                }
                return;
            }

            if (!CanControl)
            {
                return;
            }

            if (!IsCanOnUGUI && GlobalTools.IsPointerOverUGUI())
            {
                return;
            }

            if (Main.m_Input.GetButton(InputButtonType.MouseMiddle))
            {
                if (_moveTweener != null)
                {
                    _moveTweener.Kill();
                    _moveTweener = null;
                }
                Target.transform.Translate(transform.right * Main.m_Input.GetAxis(InputAxisType.MouseX) * XSpeed * MR.Distance * -1);
                Target.transform.Translate(transform.up * Main.m_Input.GetAxis(InputAxisType.MouseY) * YSpeed * MR.Distance * -1);
                MR.NeedDamping = false;
            }
            else if (Main.m_Input.GetAxisRaw(InputAxisType.Horizontal) != 0 ||
                     Main.m_Input.GetAxisRaw(InputAxisType.Vertical) != 0 ||
                     Main.m_Input.GetAxisRaw(InputAxisType.UpperLower) != 0)
            {
                if (_moveTweener != null)
                {
                    _moveTweener.Kill();
                    _moveTweener = null;
                }
                Target.transform.Translate(transform.right * Main.m_Input.GetAxis(InputAxisType.Horizontal) * XSpeed);
                Target.transform.Translate(transform.forward * Main.m_Input.GetAxis(InputAxisType.Vertical) * ZSpeed);
                Target.transform.Translate(transform.up * Main.m_Input.GetAxis(InputAxisType.UpperLower) * YSpeed);
                MR.NeedDamping = false;
            }
            else
            {
                MR.NeedDamping = true;
            }
        }
예제 #7
0
        private void OnMouseDown()
        {
            if (IsCanDrag)
            {
                if (GlobalTools.IsPointerOverUGUI())
                {
                    return;
                }

                Vector3 mousePoint  = Main.m_Input.MousePosition;
                Vector3 screenPoint = Main.m_Controller.MainCamera.WorldToScreenPoint(transform.position);
                mousePoint.z = screenPoint.z = 0;
                _offset      = screenPoint - mousePoint;
            }
        }
예제 #8
0
        private void OnMouseDrag()
        {
            if (IsAllowDrag)
            {
                if (GlobalTools.IsPointerOverUGUI())
                {
                    return;
                }

                Vector3 mousePoint  = Main.m_Input.MousePosition;
                Vector3 screenPoint = Main.m_Controller.MainCamera.WorldToScreenPoint(transform.position);
                mousePoint.z       = screenPoint.z;
                transform.position = Main.m_Controller.MainCamera.ScreenToWorldPoint(mousePoint + _offset);
            }
        }
예제 #9
0
        /// <summary>
        /// 刷新
        /// </summary>
        public void OnRefresh()
        {
            if (!CanControl)
            {
                return;
            }

            if (!IsCanOnUGUI && GlobalTools.IsPointerOverUGUI())
            {
                return;
            }

            if (Main.m_Input.GetButton(InputButtonType.MouseMiddle))
            {
                if (_moveTweener != null)
                {
                    _moveTweener.Kill();
                    _moveTweener = null;
                }
                Target.transform.Translate(transform.right * Main.m_Input.GetAxis(InputAxisType.MouseX) * XSpeed * MR.Distance * -1);
                Target.transform.Translate(transform.up * Main.m_Input.GetAxis(InputAxisType.MouseY) * YSpeed * MR.Distance * -1);
                MR.NeedDamping = false;
            }
            else if (Main.m_Input.GetAxisRaw(InputAxisType.Horizontal) != 0 ||
                     Main.m_Input.GetAxisRaw(InputAxisType.Vertical) != 0 ||
                     Main.m_Input.GetAxisRaw(InputAxisType.UpperLower) != 0)
            {
                if (_moveTweener != null)
                {
                    _moveTweener.Kill();
                    _moveTweener = null;
                }
                Target.transform.Translate(transform.right * Main.m_Input.GetAxis(InputAxisType.Horizontal) * XSpeed);
                Target.transform.Translate(transform.forward * Main.m_Input.GetAxis(InputAxisType.Vertical) * ZSpeed);
                Target.transform.Translate(transform.up * Main.m_Input.GetAxis(InputAxisType.UpperLower) * YSpeed);
                MR.NeedDamping = false;
            }
            else
            {
                MR.NeedDamping = true;
            }

            if (NeedLimit)
            {
                Target.transform.position = GlobalTools.Clamp(Target.transform.position, XMinLimit, YMinLimit, ZMinLimit, XMaxLimit, YMaxLimit, ZMaxLimit);
            }
        }
예제 #10
0
        /// <summary>
        /// 刷新
        /// </summary>
        public void Refresh()
        {
            if (!CanControl)
            {
                return;
            }

            if (!IsCanOnUGUI && GlobalTools.IsPointerOverUGUI())
            {
                return;
            }

            if (Main.m_Input.GetButton("MouseMiddle"))
            {
                if (_moveTweener != null)
                {
                    _moveTweener.Kill();
                    _moveTweener = null;
                }
                Target.transform.Translate(transform.right * Main.m_Input.GetAxis("MouseX") * XSpeed * MR.Distance * -1);
                Target.transform.Translate(transform.up * Main.m_Input.GetAxis("MouseY") * YSpeed * MR.Distance * -1);
                MR.NeedDamping = false;
            }
            else if (Main.m_Input.GetAxisRaw("Horizontal") != 0 || Main.m_Input.GetAxisRaw("Vertical") != 0)
            {
                if (_moveTweener != null)
                {
                    _moveTweener.Kill();
                    _moveTweener = null;
                }
                Target.transform.Translate(transform.right * Main.m_Input.GetAxis("Horizontal") * XSpeed);
                Target.transform.Translate(transform.forward * Main.m_Input.GetAxis("Vertical") * YSpeed);
                MR.NeedDamping = false;
            }
            else
            {
                MR.NeedDamping = true;
            }

            if (NeedLimit)
            {
                if (Target.transform.position.x < XMinLimit)
                {
                    _finalPosition.Set(XMinLimit, Target.transform.position.y, Target.transform.position.z);
                    Target.transform.position = _finalPosition;
                }
                else if (Target.transform.position.x > XMaxLimit)
                {
                    _finalPosition.Set(XMaxLimit, Target.transform.position.y, Target.transform.position.z);
                    Target.transform.position = _finalPosition;
                }

                if (Target.transform.position.y < YMinLimit)
                {
                    _finalPosition.Set(Target.transform.position.x, YMinLimit, Target.transform.position.z);
                    Target.transform.position = _finalPosition;
                }
                else if (Target.transform.position.y > YMaxLimit)
                {
                    _finalPosition.Set(Target.transform.position.x, YMaxLimit, Target.transform.position.z);
                    Target.transform.position = _finalPosition;
                }

                if (Target.transform.position.z < ZMinLimit)
                {
                    _finalPosition.Set(Target.transform.position.x, Target.transform.position.y, ZMinLimit);
                    Target.transform.position = _finalPosition;
                }
                else if (Target.transform.position.z > ZMaxLimit)
                {
                    _finalPosition.Set(Target.transform.position.x, Target.transform.position.y, ZMaxLimit);
                    Target.transform.position = _finalPosition;
                }
            }
        }