예제 #1
0
 public static void InitViewportControl(DragReceiver drag_)
 {
     _drag = drag_;
     _drag.WhenDragBegin = d => {
         _focusOverride             = _dragFocusOverride;
         _dragInertiaValue          = 0;
         CameraSystem.WorldPosition = MainCamera.transform.position;
     };
     _drag.WhenDrag = (d, offset, pos) => {
         var targetX = CameraSystem.X + offset.x * UnitPerPixel;
         var targetY = CameraSystem.Y + offset.y * UnitPerPixel;
         if (PositionLimit != null)
         {
             (targetX, targetY) = PositionLimit.Limit(targetX, targetY);
         }
         MainCamera.transform.position = CameraSystem.SystemToWorld(
             targetX,
             targetY,
             CameraSystem.Z);
         OnDrag.Invoke(offset, new Vector3(targetX, targetY, CameraSystem.Z));
     };
     _drag.WhenDragEnd = (d, delta) => {
         _focusOverride             = false;
         _dragInertiaValue          = delta.magnitude;
         _dragInertiaDelta          = delta / _dragInertiaValue;
         CameraSystem.WorldPosition = MainCamera.transform.position;
     };
     _drag.WhenPinch = (d, start, distance) => {
         var diff = (distance - start) * zoomSetting.dragFactor * zoomSetting.range * _screenHeightInverse;
         TargetZoom(_zoomTarget - diff);
     };
     ViewportControl(true);
 }