Ejemplo n.º 1
0
        /// <summary>
        /// Update component.
        /// </summary>
        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                if (menuForm == null || menuForm.IsDisposed)
                {
                    return;
                }

                if (EventSystemUtility.CheckPointerOverGameObject(menuForm.RectTrans.gameObject))
                {
                    return;
                }
                OnMenuTriggerExit();
            }
            else if (Input.GetMouseButtonDown(1))
            {
                if (menuForm != null && !menuForm.IsDisposed)
                {
                    if (EventSystemUtility.CheckPointerOverGameObject(menuForm.RectTrans.gameObject))
                    {
                        return;
                    }
                    OnMenuTriggerExit();
                }

                var ray = RayCamera.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out RaycastHit hitInfo, maxDistance, layerMask))
                {
                    OnMenuTriggerEnter(hitInfo);
                }
            }
        }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        protected virtual void Update()
        {
            if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
            {
                CloseCurrentMenu();
            }
            else if (Input.GetMouseButtonDown(1))
            {
                CloseCurrentMenu();

                var ray     = RayCamera.ScreenPointToRay(Input.mousePosition);
                var hitInfo = new RaycastHit();
                if (Physics.Raycast(ray, out hitInfo, maxDistance, layerMask))
                {
                    var menuAgent = hitInfo.transform.GetComponent <IContextMenuAgent>();
                    if (menuAgent != null)
                    {
                        CurrentMenu = FindContextMenu(menuAgent.MenuName);
                        if (CurrentMenu != null)
                        {
                            CurrentMenu.Show(menuAgent, Input.mousePosition);
                        }
                    }
                }
            }
        }