private void HandleDragging() { Touch[] touches = Input.touches; if (touches.Length == 0) { SetCurrentState(TouchInputState.TAPPING); } else { OnDragDelta?.Invoke(touches[0].deltaPosition); } if (touches.Length == 2) { float delta = InputUtils.GetTouchDistanceDelta(touches[0], touches[1]); if (Mathf.Abs(delta) > _PinchThreshold) { SetCurrentState(TouchInputState.PINCHING); } } }
private void HandleDebugKeyboard() { #if UNITY_EDITOR Vector2 moveDelta = Vector2.zero; moveDelta.x = -Input.GetAxis("Horizontal") * 8; moveDelta.y = -Input.GetAxis("Vertical") * 8; float scrolldelta = 0; if (Input.GetKey(KeyCode.Q)) { scrolldelta -= 0.2f; } if (Input.GetKey(KeyCode.E)) { scrolldelta += 0.2f; } OnDragDelta?.Invoke(moveDelta); OnPinchDelta?.Invoke(scrolldelta); #endif }
private void HandleDebugMouse() { #if UNITY_EDITOR if (Input.GetMouseButtonDown(1)) { _PreviousMousePosition = Input.mousePosition; OnDragStart?.Invoke(); } if (Input.GetMouseButton(1)) { Vector2 mousePos = new Vector2(Input.mousePosition.x, Input.mousePosition.y); OnDragDelta?.Invoke((mousePos - _PreviousMousePosition) * 2); _PreviousMousePosition = Input.mousePosition; } if (Input.GetMouseButtonUp(1)) { OnDragStop?.Invoke(); } OnPinchDelta?.Invoke(Input.mouseScrollDelta.y * 45); if (Input.GetMouseButtonDown(0)) { OnTap?.Invoke(); if (!ShootGraphicsRays(Input.mousePosition)) { if (!ShootPhysicsRay(Input.mousePosition)) { OnDeselect?.Invoke(); } } } #endif }