public void Move(GestureInfoPan info) { if (!uiUtils.IsPointerOverUIElement()) { _cm.Move(-info.deltaDirection * 0.01f); } }
public void CallbackPanning(GestureInfoPan pan) { CameraController._instance.orbitSpeed += pan.deltaDirection.x; if (Mathf.Sign(CameraController._instance.orbitSpeed) != Mathf.Sign(pan.deltaDirection.x)) { CameraController._instance.orbitSpeed = pan.deltaDirection.x; } this.AddMessage("Panning"); }
protected override void OnMoved(TouchInfo touchInfo) { GestureInfoPan gesture = new GestureInfoPan(touchInfo.GetDeltaPosition(), TouchPhase.Moved); if (this.broadcastWhilePanningI != null) { this.broadcastWhilePanningI(gesture); } if (this.broadcastWhilePanning != null) { this.broadcastWhilePanning(); } }
protected override void OnEnded(TouchInfo touchInfo1, TouchInfo touchInfo2) { Vector2 position1 = touchInfo1.GetLastPosition(); Vector2 position2 = touchInfo2.GetLastPosition(); Vector2 center = (position1 + position2) / 2f; GestureInfoPan gesurePan = new GestureInfoPan(Vector2.zero, TouchPhase.Ended); if (this.broadcastWhilePanning != null) { this.broadcastWhilePanning(); } if (this.broadcastWhilePanningI != null) { this.broadcastWhilePanningI(gesurePan); } GestureInfoZoom gestureZoom = new GestureInfoZoom(0f, center, position1, position2, TouchPhase.Ended); if (this.broadcastWhilePinching != null) { this.broadcastWhilePinching(); } if (this.broadcastWhilePinchingI != null) { this.broadcastWhilePinchingI(gestureZoom); } if (this.broadcastWhileStretching != null) { this.broadcastWhileStretching(); } if (this.broadcastWhileStretchingI != null) { this.broadcastWhileStretchingI(gestureZoom); } GestureInfoTwist gesture = new GestureInfoTwist(center, 0f, position1, position2, true, TouchPhase.Ended); if (this.broadcastWhileTwisting != null) { this.broadcastWhileTwisting(); } if (this.broadcastWhileTwistingI != null) { this.broadcastWhileTwistingI(gesture); } }
// OVERRIDES: ------------------------------------------------------------------------------------------------------ protected override void OnMoved(TouchInfo touchInfo1, TouchInfo touchInfo2) { if (touchInfo1.GetDeltaPosition() == Vector2.zero) { return; } if (touchInfo2.GetDeltaPosition() == Vector2.zero) { return; } Vector2 direction1 = touchInfo1.GetLastPosition() - (touchInfo1.GetLastPosition() - touchInfo1.GetDeltaPosition()); Vector2 direction2 = touchInfo2.GetLastPosition() - (touchInfo2.GetLastPosition() - touchInfo2.GetDeltaPosition()); float angle = Vector2.Angle(direction1, direction2); Vector2 center = Vector2.zero; center += touchInfo1.GetLastPosition() - touchInfo1.GetDeltaPosition(); center += touchInfo2.GetLastPosition() - touchInfo2.GetDeltaPosition(); center /= 2.0f; Vector2 dirCenter1 = (touchInfo1.GetLastPosition() - touchInfo1.GetDeltaPosition()) - center; Vector2 dirCenter2 = (touchInfo2.GetLastPosition() - touchInfo2.GetDeltaPosition()) - center; float dot1 = Vector3.Dot(dirCenter1.normalized, direction1.normalized); float dot2 = Vector3.Dot(dirCenter2.normalized, direction2.normalized); float angle1 = Mathf.Acos(dot1) * Mathf.Rad2Deg; float angle2 = Mathf.Acos(dot2) * Mathf.Rad2Deg; if (this.IsPanning(angle)) { GestureInfoPan gesture = new GestureInfoPan(touchInfo1.GetDeltaPosition()); if (this.broadcastWhilePanning != null) { this.broadcastWhilePanning(); } if (this.broadcastWhilePanningI != null) { this.broadcastWhilePanningI(gesture); } } if (this.IsPinching(angle1, angle2)) { float t_delta = direction1.magnitude + direction2.magnitude; Vector2 t_position1 = touchInfo1.GetLastPosition(); Vector2 t_position2 = touchInfo2.GetLastPosition(); Vector2 t_center = (t_position1 + t_position2) / 2.0f; GestureInfoZoom gesture = new GestureInfoZoom(t_delta, t_center, t_position1, t_position2); if (this.broadcastWhilePinching != null) { this.broadcastWhilePinching(); } if (this.broadcastWhilePinchingI != null) { this.broadcastWhilePinchingI(gesture); } } if (this.IsStretching(angle1, angle2)) { float t_delta = direction1.magnitude + direction2.magnitude; Vector2 t_position1 = touchInfo1.GetLastPosition(); Vector2 t_position2 = touchInfo2.GetLastPosition(); Vector2 t_center = (t_position1 + t_position2) / 2.0f; GestureInfoZoom gesture = new GestureInfoZoom(t_delta, t_center, t_position1, t_position2); if (this.broadcastWhileStretching != null) { this.broadcastWhileStretching(); } if (this.broadcastWhileStretchingI != null) { this.broadcastWhileStretchingI(gesture); } } if (this.IsTwisting(angle1, angle2)) { Vector2 t_pos1 = touchInfo1.GetLastPosition(); Vector2 t_pos2 = touchInfo2.GetLastPosition(); Vector2 t_center = (t_pos1 + t_pos2) / 2.0f; float t_delta = direction1.magnitude + direction2.magnitude; bool t_clockwise; if (t_pos1.y > t_pos2.y) { t_clockwise = (direction1.x < 0.0f ? false : true); } else { t_clockwise = (direction2.x < 0.0f ? false : true); } GestureInfoTwist gesture = new GestureInfoTwist(t_center, t_delta, t_pos1, t_pos2, t_clockwise); if (this.broadcastWhileTwisting != null) { this.broadcastWhileTwisting(); } if (this.broadcastWhileTwistingI != null) { this.broadcastWhileTwistingI(gesture); } } }