public void MouseHandler(MouseState mouseState, MouseState LastMouseState) { if (isDisponse) { return; } if (mouseState.LeftButton == ButtonState.Pressed) { LBMPressed?.Invoke(mouseState, LastMouseState); } if (mouseState.LeftButton == ButtonState.Pressed && LastMouseState.LeftButton == ButtonState.Released) { LBMDown?.Invoke(mouseState, LastMouseState); } if (mouseState.LeftButton == ButtonState.Released && LastMouseState.LeftButton == ButtonState.Pressed) { LBMUp?.Invoke(mouseState, LastMouseState); } if (mouseState.RightButton == ButtonState.Pressed) { RBMPressed?.Invoke(mouseState, LastMouseState); } if (mouseState.RightButton == ButtonState.Pressed && LastMouseState.RightButton == ButtonState.Released) { RBMDown?.Invoke(mouseState, LastMouseState); } if (mouseState.RightButton == ButtonState.Released && LastMouseState.RightButton == ButtonState.Pressed) { RBMUp?.Invoke(mouseState, LastMouseState); } }
void Update() { LBMPressedFlag = Input.GetMouseButtonDown(0) && !IsUIObject(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits = Physics.RaycastAll(ray, 100.0f); for (int i = 0; i < hits.Length; i++) { if (i == 0) { CursorPosition?.Invoke(GetPosition(hits[i])); } Selected = SelectObject(hits[i]); } if (LBMPressedFlag) { LBMPressed?.Invoke(); } }