public override void OnUpdate() { //处理鼠标事件 当点击UI面板时不处理 if (!EventSystem.current.IsPointerOverGameObject()) { if (Input.GetMouseButtonDown(0)) { CurrentMouseState.OnLeftButtonDown(); } else if (Input.GetMouseButton(0)) { CurrentMouseState.OnLeftButtonHold(); } else if (Input.GetMouseButtonUp(0)) { CurrentMouseState.OnLeftButtonUp(); } else if (Input.GetMouseButtonDown(1)) { CurrentMouseState.OnRightButtonDown(); } else if (Input.GetMouseButton(1)) { CurrentMouseState.OnRightButtonHold(); } else if (Input.GetMouseButtonUp(1)) { CurrentMouseState.OnRightButtonUp(); } else if (Input.GetMouseButtonDown(2)) { CurrentMouseState.OnCenterButtonDown(); } else if (Input.GetMouseButton(2)) { CurrentMouseState.OnCenterButtonHold(); } else if (Input.GetMouseButtonUp(2)) { CurrentMouseState.OnCenterButtonUp(); } } CurrentMouseState.OnUpdate(); if (Input.mousePosition != lastPosition) { lastPosition = Input.mousePosition; MouseMove = true; } else { MouseMove = false; } }
private void statusLabel_Paint(object sender, PaintEventArgs e) { statusLabel.Text = CurrentMouseState.ToString(); }