コード例 #1
0
    /// <summary>
    /// 通过unity和window坐标系进行转换后模拟鼠标
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    IEnumerator Simulater(InputData data)
    {
        Vector2 pointStart = MouseSimulater.UnityScreenToWindowPos(data.pointStart_Unity);
        Vector2 pointEnd   = MouseSimulater.UnityScreenToWindowPos(data.pointEnd_Unity);

        MouseSimulater.MoveTo(pointStart.x, pointStart.y);
        MouseSimulater.LeftClickDown();
        yield return(null);

        m_Wait = new WaitForSecondsRealtime(data.pressTime / Frequency);
        for (int i = 1; i <= Frequency; i++)
        {
            Vector2 point = Vector2.Lerp(pointStart, pointEnd, i / (float)Frequency);
            MouseSimulater.MoveTo(point.x, point.y);
            yield return(m_Wait);
        }
        MouseSimulater.LeftClickUp();
        yield return(null);

        //这边可以开递归去把队列里面全部出队
        if (m_InputQueue.Count > 0)
        {
            StartCoroutine(Simulater(m_InputQueue.Dequeue()));
        }
        else
        {
            m_IsSimulater = false;
        }
    }
コード例 #2
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0) && m_IsSimulater == false)
        {
            m_BeginClickPoint = Input.mousePosition;
            POINT point = default;
            MouseSimulater.GetCursorPos(ref point);
            m_BeginClick_Point = point;
            //print("m_BeginClickPoint=" + m_BeginClickPoint);
            m_Timer = Time.time;
        }
        if (Input.GetMouseButtonUp(0) && m_IsSimulater == false)
        {
            POINT point = default;
            MouseSimulater.GetCursorPos(ref point);

            m_InputQueue.Enqueue(new InputData(InputType.Click, m_BeginClickPoint, Input.mousePosition, m_BeginClick_Point, point, Time.time - m_Timer));
            print("Time.time - m_Timer=" + (Time.time - m_Timer));
        }
        if (Input.GetKeyDown(KeyCode.T))
        {
            if (m_InputQueue != null && m_InputQueue.Count > 0)
            {
                m_IsSimulater = true;
                //StartCoroutine(Simulater(m_InputQueue.Dequeue()));
                StartCoroutine(SimulaterByWindow(m_InputQueue.Dequeue()));
            }
        }
    }
コード例 #3
0
 private void PosCallBack(string arg0)
 {
     if (posX.text == "" | posY.text == "")
     {
         return;
     }
     MouseSimulater.LeftClick(float.Parse(posX.text), float.Parse(posY.text));
     Restext.text = "当前Unity分辨率:" + Screen.width + " / " + Screen.height + "当前点击:" + posX.text + " / " + posY.text;
 }
コード例 #4
0
        public override void HandleCommand(CommadMessage message)
        {
            string msg = GetRequestType(message.Message);
            switch (msg)
            {
                case "mouseclickleft":
                    MouseSimulater.MoveTo(new System.Drawing.Point(int.Parse(argumentList[0]), int.Parse(argumentList[1])));
                    MouseSimulater.Click_Left(int.Parse(argumentList[0]), int.Parse(argumentList[1]));
                    break;

                case "mouseclickright":
                    MouseSimulater.MoveTo(new System.Drawing.Point(int.Parse(argumentList[0]), int.Parse(argumentList[1])));
                    MouseSimulater.Click_Right(int.Parse(argumentList[0]), int.Parse(argumentList[1]));
                    break;
                default:
                    nextCommandHandler.HandleCommand(message);
                    break;
            }
            
        }
コード例 #5
0
        public void OnGUI()
        {
            if (!(Loader.is1637663252 | Loader.is583429740 | Loader.is1806963141))
            {
                return;
            }

            if ((laterLeftClick == 8) && needLaterLeftClick)
            {
                laterLeftClick = 0;
                MouseSimulater.LeftClick();
                needLaterLeftClick = false;
            }
            else if (needLaterLeftClick)
            {
                laterLeftClick++;
            }

            var e = Event.current;

            // Checking key presses
            if (OptionsKeymappingFunction.m_stayinlane.IsPressed(e))
            {
                Assembly TMPE               = Assembly.Load("TrafficManager");
                var      selectedNodeId     = TMPE.GetType("TrafficManager.UI.TrafficManagerTool").GetProperty("SelectedNodeId");
                var      TrafficManagerTool = TMPE.CreateInstance("TrafficManager.UI.TrafficManagerTool");
                ushort   node               = (ushort)selectedNodeId.GetValue(TrafficManagerTool, null);
                DebugLog.LogToFileOnly("TMPE select node = " + node.ToString());
                NetInfo asset = Singleton <NetManager> .instance.m_nodes.m_buffer[node].Info;
                if (CSURUtil.IsCSUR(asset))
                {
                    bool IsCSURRLane  = false;
                    bool IsCSURDual   = false;
                    bool IsCSURSingle = false;
                    for (int j = 0; j < 8; j++)
                    {
                        ushort segmentID = Singleton <NetManager> .instance.m_nodes.m_buffer[node].GetSegment(j);
                        if (segmentID != 0)
                        {
                            var segment = Singleton <NetManager> .instance.m_segments.m_buffer[segmentID];
                            if (CSURUtil.IsCSUR(segment.Info))
                            {
                                if (CSURUtil.IsCSURDual(segment.Info))
                                {
                                    IsCSURDual = true;
                                }
                                else
                                {
                                    if (CSURUtil.IsCSURRLaneOffset(segment.Info))
                                    {
                                        IsCSURRLane = true;
                                        break;
                                    }
                                    IsCSURSingle = true;
                                }
                            }
                        }
                    }
                    if (IsCSURRLane || (IsCSURDual && IsCSURSingle))
                    {
                        AddLaneConnectionForCSUR(node, TMPE);
                        //refresh
                        MouseSimulater.RightClick();
                        needLaterLeftClick = true;
                    }
                }
            }

            if (OptionsKeymappingFunction.m_stayinlaneAll.IsPressed(e))
            {
                Assembly TMPE = Assembly.Load("TrafficManager");
                for (ushort i = 0; i < Singleton <NetManager> .instance.m_nodes.m_size; i++)
                {
                    bool IsCSURRLane  = false;
                    bool IsCSURDual   = false;
                    bool IsCSURSingle = false;
                    for (int j = 0; j < 8; j++)
                    {
                        ushort segmentID = Singleton <NetManager> .instance.m_nodes.m_buffer[i].GetSegment(j);
                        if (segmentID != 0)
                        {
                            var segment = Singleton <NetManager> .instance.m_segments.m_buffer[segmentID];
                            if (CSURUtil.IsCSUR(segment.Info))
                            {
                                if (CSURUtil.IsCSURDual(segment.Info))
                                {
                                    IsCSURDual = true;
                                }
                                else
                                {
                                    if (CSURUtil.IsCSURRLaneOffset(segment.Info))
                                    {
                                        IsCSURRLane = true;
                                        break;
                                    }
                                    IsCSURSingle = true;
                                }
                            }
                        }
                    }
                    if (IsCSURRLane || (IsCSURDual && IsCSURSingle))
                    {
                        AddLaneConnectionForCSUR(i, TMPE);
                    }
                }
            }
        }