Beispiel #1
0
 public void Update()
 {
     DragGestureRecognizer.Update();
     PinchGestureRecognizer.Update();
     TwoFingerDragGestureRecognizer.Update();
     TapGestureRecognizer.Update();
     TwistGestureRecognizer.Update();
 }
Beispiel #2
0
 /// <summary>
 /// Constructs a PinchGesture gesture.
 /// </summary>
 /// <param name="recognizer">The gesture recognizer.</param>
 /// <param name="touch1">The first touch that started this gesture.</param>
 /// <param name="touch2">The second touch that started this gesture.</param>
 public TwistGesture(TwistGestureRecognizer recognizer, Touch touch1, Touch touch2) :
     base(recognizer)
 {
     FingerId1      = touch1.fingerId;
     FingerId2      = touch2.fingerId;
     StartPosition1 = touch1.position;
     StartPosition2 = touch2.position;
 }
Beispiel #3
0
        private void DisconnectFromRecognizers()
        {
            if (ManipulationSystem.Instance == null)
            {
                Debug.LogError("Manipulation system not found in scene.");
                return;
            }

            DragGestureRecognizer dragGestureRecognizer =
                ManipulationSystem.Instance.DragGestureRecognizer;

            if (dragGestureRecognizer != null)
            {
                dragGestureRecognizer.onGestureStarted -= OnGestureStarted;
            }

            PinchGestureRecognizer pinchGestureRecognizer =
                ManipulationSystem.Instance.PinchGestureRecognizer;

            if (pinchGestureRecognizer != null)
            {
                pinchGestureRecognizer.onGestureStarted -= OnGestureStarted;
            }

            TapGestureRecognizer tapGestureRecognizer =
                ManipulationSystem.Instance.TapGestureRecognizer;

            if (tapGestureRecognizer != null)
            {
                tapGestureRecognizer.onGestureStarted -= OnGestureStarted;
            }

            TwistGestureRecognizer twistGestureRecognizer =
                ManipulationSystem.Instance.TwistGestureRecognizer;

            if (twistGestureRecognizer != null)
            {
                twistGestureRecognizer.onGestureStarted -= OnGestureStarted;
            }

            TwoFingerDragGestureRecognizer twoFingerDragGestureRecognizer =
                ManipulationSystem.Instance.TwoFingerDragGestureRecognizer;

            if (twoFingerDragGestureRecognizer != null)
            {
                twoFingerDragGestureRecognizer.onGestureStarted -= OnGestureStarted;
            }
        }
Beispiel #4
0
        /// <summary>
        /// Returns true if this gesture can start.
        /// </summary>
        /// <returns>True if the gesture can start.</returns>
        protected internal override bool CanStart()
        {
            if (GestureTouchesUtility.IsFingerIdRetained(FingerId1) ||
                GestureTouchesUtility.IsFingerIdRetained(FingerId2))
            {
                Cancel();
                return(false);
            }

            Touch touch1, touch2;
            bool  foundTouches = GestureTouchesUtility.TryFindTouch(FingerId1, out touch1);

            foundTouches =
                GestureTouchesUtility.TryFindTouch(FingerId2, out touch2) && foundTouches;

            if (!foundTouches)
            {
                Cancel();
                return(false);
            }

            // Check that both fingers are moving.
            if (touch1.deltaPosition == Vector2.zero || touch2.deltaPosition == Vector2.zero)
            {
                return(false);
            }

            TwistGestureRecognizer twistRecognizer = Recognizer as TwistGestureRecognizer;

            float rotation = CalculateDeltaRotation(
                touch1.position, touch2.position, StartPosition1, StartPosition2);

            if (Mathf.Abs(rotation) < twistRecognizer.SlopRotation)
            {
                return(false);
            }

            return(true);
        }