Esempio n. 1
0
 /// <summary>
 /// Called on input release
 /// </summary>
 protected virtual void OnRelease(PointerActionInfo pointer)
 {
     if (cameraRig != null)
     {
         DoReleaseFlick(pointer);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Called on input press
 /// </summary>
 protected virtual void OnPress(PointerActionInfo pointer)
 {
     if (cameraRig != null)
     {
         DoFlickCatch(pointer);
     }
 }
 /// <summary>
 /// Called on input press, for MMB panning
 /// </summary>
 protected virtual void OnPress(PointerActionInfo pointer)
 {
     if (cameraRig != null)
     {
         DoMiddleMousePan(pointer);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Do flicks, on release only
        /// </summary>
        /// <param name="pointer">The release pointer event</param>
        protected void DoReleaseFlick(PointerActionInfo pointer)
        {
            var touchInfo = pointer as TouchInfo;

            if (touchInfo != null && touchInfo.flickVelocity.sqrMagnitude > Mathf.Epsilon)
            {
                // We have a flick!
                // Work out velocity from motion
                Ray prevRay = cameraRig.cachedCamera.ScreenPointToRay(pointer.currentPosition -
                                                                      pointer.flickVelocity);
                Ray currRay = cameraRig.cachedCamera.ScreenPointToRay(pointer.currentPosition);

                Vector3 startPoint = Vector3.zero;
                Vector3 endPoint   = Vector3.zero;
                float   dist;

                if (cameraRig.floorPlane.Raycast(prevRay, out dist))
                {
                    startPoint = prevRay.GetPoint(dist);
                }
                if (cameraRig.floorPlane.Raycast(currRay, out dist))
                {
                    endPoint = currRay.GetPoint(dist);
                }

                // Work out that movement in units per second
                m_FlickDirection = (startPoint - endPoint) / Time.deltaTime;
            }
        }
 /// <summary>
 /// Called when we drag
 /// </summary>
 protected virtual void OnDrag(PointerActionInfo pointer)
 {
     if (cameraRig != null)
     {
         DoRightMouseDragPan(pointer);
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Controls the pan with a drag
        /// </summary>
        protected void DoDragPan(PointerActionInfo pointer)
        {
            var touchInfo = pointer as TouchInfo;

            if (touchInfo != null)
            {
                // Work out movement amount by raycasting onto floor plane from delta positions
                // and getting that distance
                Ray currRay = cameraRig.cachedCamera.ScreenPointToRay(touchInfo.currentPosition);

                Vector3 endPoint = Vector3.zero;
                float   dist;
                if (cameraRig.floorPlane.Raycast(currRay, out dist))
                {
                    endPoint = currRay.GetPoint(dist);
                }
                // Pan
                Ray     prevRay    = cameraRig.cachedCamera.ScreenPointToRay(touchInfo.previousPosition);
                Vector3 startPoint = Vector3.zero;

                if (cameraRig.floorPlane.Raycast(prevRay, out dist))
                {
                    startPoint = prevRay.GetPoint(dist);
                }
                Vector3 panAmount = startPoint - endPoint;
                // If this is a touch, we divide the pan amount by the number of touches
                if (UnityInput.touchCount > 0)
                {
                    panAmount /= UnityInput.touchCount;
                }

                PanCamera(panAmount);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Called when we drag
 /// </summary>
 protected virtual void OnDrag(PointerActionInfo pointer)
 {
     // Drag panning for touch input
     if (cameraRig != null)
     {
         DoDragPan(pointer);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Controls the pan with a drag
        /// </summary>
        protected void DoDragPan(PointerActionInfo pointer)
        {
            var touchInfo = pointer as TouchInfo;

            if (touchInfo != null)
            {
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Do flicks, on release only
        /// </summary>
        /// <param name="pointer">The release pointer event</param>
        protected void DoReleaseFlick(PointerActionInfo pointer)
        {
            var touchInfo = pointer as TouchInfo;

            if (touchInfo != null && touchInfo.flickVelocity.sqrMagnitude > Mathf.Epsilon)
            {
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Update a TouchInfo with movement
        /// </summary>
        /// <param name="touch">The Unity touch object</param>
        /// <param name="existingTouch">The object that's tracking Unity's touch</param>
        void UpdateMovingFinger(Touch touch, PointerActionInfo existingTouch)
        {
            float dragDist = touch.deltaPosition.magnitude;

            existingTouch.previousPosition = existingTouch.currentPosition;
            existingTouch.currentPosition  = touch.position;
            existingTouch.delta            = touch.deltaPosition;
            existingTouch.totalMovement   += dragDist;
        }
Esempio n. 11
0
        /// <summary>
        /// "Catch" flicks on press, to stop the panning momentum
        /// </summary>
        /// <param name="pointer">The press pointer event</param>
        protected void DoFlickCatch(PointerActionInfo pointer)
        {
            var touchInfo = pointer as TouchInfo;

            // Stop flicks on touch
            if (touchInfo != null)
            {
                m_FlickDirection = Vector2.zero;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Pan with middle mouse
        /// </summary>
        /// <param name="pointer">Pointer with press event</param>
        protected void DoMiddleMousePan(PointerActionInfo pointer)
        {
            var mouseInfo = pointer as MouseButtonInfo;

            // Pan to mouse position on MMB
            if ((mouseInfo != null) &&
                (mouseInfo.mouseButtonId == 2))
            {
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Update a TouchInfo that might be holding
 /// </summary>
 /// <param name="existingTouch"></param>
 void UpdateHoldingFinger(PointerActionInfo existingTouch)
 {
     if (!existingTouch.isHold &&
         !existingTouch.isDrag &&
         Time.realtimeSinceStartup - existingTouch.startTime >= holdTime)
     {
         existingTouch.isHold = true;
         if (startedHold != null)
         {
             startedHold(existingTouch);
         }
     }
 }
        /// <summary>
        /// Pan with right mouse
        /// </summary>
        /// <param name="pointer">The drag pointer event</param>
        protected void DoRightMouseDragPan(PointerActionInfo pointer)
        {
            var mouseInfo = pointer as MouseButtonInfo;

            if ((mouseInfo != null) &&
                (mouseInfo.mouseButtonId == 1))
            {
                // Calculate zoom ratio
                float zoomRatio = GetPanSpeedForZoomLevel();

                Vector2 panVector = mouseInfo.currentPosition - mouseInfo.startPosition;
                panVector = (panVector * Time.deltaTime * mouseRmbPanSpeed * zoomRatio) / screenPanThreshold;

                var camVector = new Vector3(panVector.x, 0, panVector.y);
                cameraRig.PanCamera(camVector);

                cameraRig.StopTracking();
            }
        }
        /// <summary>
        /// Pan with middle mouse
        /// </summary>
        /// <param name="pointer">Pointer with press event</param>
        protected void DoMiddleMousePan(PointerActionInfo pointer)
        {
            var mouseInfo = pointer as MouseButtonInfo;

            // Pan to mouse position on MMB
            if ((mouseInfo != null) &&
                (mouseInfo.mouseButtonId == 2))
            {
                // First get floor position of cursor
                Ray ray = cameraRig.cachedCamera.ScreenPointToRay(UnityInput.mousePosition);

                float dist;

                if (cameraRig.floorPlane.Raycast(ray, out dist))
                {
                    Vector3 worldPos = ray.GetPoint(dist);
                    cameraRig.PanTo(worldPos);
                }

                cameraRig.StopTracking();
            }
        }
Esempio n. 16
0
 /// <summary>
 /// Called on input release
 /// </summary>
 protected virtual void OnRelease(PointerActionInfo pointer)
 {
     DoReleaseFlick(pointer);
 }
Esempio n. 17
0
 /// <summary>
 /// Called on input press
 /// </summary>
 protected virtual void OnPress(PointerActionInfo pointer)
 {
     DoFlickCatch(pointer);
 }
Esempio n. 18
0
        /// <summary>
        /// Called when we drag
        /// </summary>
        protected virtual void OnDrag(PointerActionInfo pointer)
        {
            // Drag panning for touch input

            DoDragPan(pointer);
        }
Esempio n. 19
0
 /// <summary>
 /// Called on input press, for MMB panning
 /// </summary>
 protected virtual void OnPress(PointerActionInfo pointer)
 {
     DoMiddleMousePan(pointer);
 }
Esempio n. 20
0
 /// <summary>
 /// Called when we drag
 /// </summary>
 protected virtual void OnDrag(PointerActionInfo pointer)
 {
 }
Esempio n. 21
0
 protected virtual void OnRelease(PointerActionInfo pointer)
 {
 }