Пример #1
0
        /// <summary>
        /// 指针滑动
        /// </summary>
        void MouseScroll()
        {
            float value = Control.instance.IsScroll();

            if (value != 0)
            {
                value = value * 100;
                GuiMouse.MouseScroll((int)value);
            }
        }
Пример #2
0
 /// <summary>
 /// 触发鼠标点击
 /// </summary>
 void MouseClick()
 {
     if (Control.instance.IsMouseLeftDoun())
     {
         GuiMouse.MouseLeftDown();
     }
     if (Control.instance.IsMouseLeftUp())
     {
         GuiMouse.MouseLeftUp();
     }
 }
Пример #3
0
        /// <summary>
        /// 指针移动
        /// </summary>
        void MouseMove()
        {
            float h = Control.instance.IsHorizontal();
            float v = Control.instance.IsVertical();

            if (v != 0 || h != 0)
            {
                GuiMouse.POINT pt = GuiMouse.GetMousePos();
                pt.X += (int)(h * 10);
                pt.Y -= (int)(v * 10);
                GuiMouse.SetMousePos(pt);
            }
        }
        /// <summary>
        /// 校准指针位置
        /// </summary>
        public void CalibrationPointerPosition()
        {
            //Cursor.lockState = CursorLockMode.None;
            // 获取鼠标的窗口坐标
            Vector2 winPos = Input.mousePosition;
            Vector2 center = new Vector2(Screen.width / 2, Screen.height / 2);

            //winPos = winPos - (winPos - center) * 2;

            //Debug.Log("窗口位置" + winPos + " " + center);
            // 获取指针的屏幕坐标
            GuiMouse.POINT screenPos = GuiMouse.GetMousePos();
            //Debug.Log("屏幕位置" + screenPos);
            //然后经过一系列的计算 嘿嘿
            offect = new Vector2(winPos.x - screenPos.X, winPos.y - screenPos.Y);
            //Debug.Log("校准指针偏移" + offect);
            Invoke("Xxxx", 0.2f);
        }
Пример #5
0
        /// <summary>
        /// 选择按钮
        /// </summary>
        void SelectBtn()
        {
            if (Control.instance.IsJudgment())
            {
                //Debug.Log("触发了选择");
                Selectable next    = null;
                Selectable current = null;

                // 找出我们是否有一个有效的当前选择的游戏对象
                if (eventSystem.currentSelectedGameObject != null)
                {
                    // Unity似乎没有“取消选择”一个不活动的对象
                    if (eventSystem.currentSelectedGameObject.activeInHierarchy)
                    {
                        current = eventSystem.currentSelectedGameObject.GetComponent <Selectable>();
                    }
                }
                if (current != null)
                {
                    // 当SHIFT与标签一起被按住时,向后移动而不是向前移动
                    if (Control.instance.IsLast())
                    {
                        //Debug.Log("触发了向前选择");
                        next = current.FindSelectableOnLeft();
                        if (next == null)
                        {
                            next = current.FindSelectableOnUp();
                        }
                    }
                    else
                    {
                        //Debug.Log("触发了向后选择");
                        next = current.FindSelectableOnRight();
                        if (next == null)
                        {
                            next = current.FindSelectableOnDown();
                            if (next == null)
                            {
                                current = eventSystem.firstSelectedGameObject.GetComponent <Selectable>();
                                next    = current;
                            }
                        }
                    }
                }
                else
                {
                    // 如果没有当前选择的游戏对象,选择第一个
                    if (Selectable.allSelectables.Count > 0)
                    {
                        next   = Selectable.allSelectables[0];
                        getCom = false;
                    }
                }

                if (next != null)
                {
                    next.Select();
                    select = next;
                    image.SetParent(next.transform, false);



                    Vector2 winPos    = uiCamera.WorldToScreenPoint(image.transform.position);
                    var     screenPos = calculationScreenPosition.CalculationScreenPos(winPos);
                    GuiMouse.SetMousePos(screenPos);
                }
            }
        }