示例#1
0
        void OnZoomGesture(InputAction.CallbackContext context)
        {
            if (OrphanUIController.isTouchBlockedByUI || m_PanGestureInProgress || !CheckTreatInput(context))
            {
                return;
            }

            var interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                var pinchGesture = interaction?.currentGesture as PinchGesture;
                if (m_ZoomGestureCoroutine != null)
                {
                    StopCoroutine(m_ZoomGestureCoroutine);
                }
                m_ZoomGestureCoroutine = StartCoroutine(StopZoomGesture());
#if UNITY_ANDROID
                // TODO: This should be the general algorithm, but we will need to test it on iOS first.
                var distance = m_GestureCameraStartPosition - (m_GestureCameraStartPosition) * ((pinchGesture.gap - pinchGesture.startGap) / Screen.height);
                if (distance > m_GestureCameraStartPosition)
                {
                    // Double zoom out ratio
                    distance += distance - m_GestureCameraStartPosition;
                }
                m_Camera.SetDistanceFromLookAt(distance);
#else
                m_ZoomDelta.SetNewFrameDelta(new Vector2(0.0f, pinchGesture.gapDelta / pinchGesture.gap) * m_ZoomGestureSensibility);
                Zoom(m_ZoomDelta.delta);
#endif
            }
        }
        void OnZoomGesture(InputAction.CallbackContext context)
        {
            if (OrphanUIController.isTouchBlockedByUI || m_PanGestureInProgress || !CheckTreatInput(context))
            {
                return;
            }

            var interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                var pinchGesture = interaction?.currentGesture as PinchGesture;
                if (m_ZoomGestureCoroutine != null)
                {
                    StopCoroutine(m_ZoomGestureCoroutine);
                }
                m_ZoomGestureCoroutine = StartCoroutine(StopZoomGesture());

                var distance = m_GestureCameraStartPosition - (m_GestureCameraStartPosition) * ((pinchGesture.gap - pinchGesture.startGap) / Screen.height);
                if (distance > m_GestureCameraStartPosition)
                {
                    // Double zoom out ratio
                    distance += distance - m_GestureCameraStartPosition;
                }

                m_Camera.SetDistanceFromLookAt(distance);
            }
        }