Exemplo n.º 1
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);
        }