ScreenHalf GetPointScreenHalf(Vector2 position) { Vector2 screenCenter = new Vector2(Screen.width, Screen.height) / 2.0f; float a = Vector2.SignedAngle(Vector2.up, screenCenter - position); if (a > 0 && a <= 180) { dragScreenHalf = ScreenHalf.Right; } else if (a > -180 && a <= 0) { dragScreenHalf = ScreenHalf.Left; } else { dragScreenHalf = ScreenHalf.None; } return(dragScreenHalf); }
void GetMouseInput() { /* * Mouse Down */ if (Input.GetMouseButtonDown(0)) { // Reset drag variables ResetInputVars(); // Get drag screen half dragScreenHalf = GetPointScreenHalf(Input.mousePosition); } /* * Mouse Drag */ isMouseDown = Input.GetMouseButton(0); if (isMouseDown) { // Only add to drag once the mouse has moved if (hasDragged) { drag += (Vector2)Input.mousePosition - previousMousePosition; } previousMousePosition = Input.mousePosition; hasDragged = true; UpdateControllables(); } /* * Mouse Up */ if (Input.GetMouseButtonUp(0)) { // TODO: release event } }