Ejemplo n.º 1
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 = m_Recognizer as TwistGestureRecognizer;

            float rotation = CalculateDeltaRotation(touch1.position, touch2.position, StartPosition1, StartPosition2);
            if (Mathf.Abs(rotation) < twistRecognizer.m_SlopRotation)
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 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;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 public void Update()
 {
     DragGestureRecognizer.Update();
     PinchGestureRecognizer.Update();
     TwoFingerDragGestureRecognizer.Update();
     TapGestureRecognizer.Update();
     TwistGestureRecognizer.Update();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// The Unity Awake() method.
 /// </summary>
 public void Awake()
 {
     _InitializeSingleton();
     DragGestureRecognizer          = new DragGestureRecognizer();
     PinchGestureRecognizer         = new PinchGestureRecognizer();
     TwoFingerDragGestureRecognizer = new TwoFingerDragGestureRecognizer();
     TapGestureRecognizer           = new TapGestureRecognizer();
     TwistGestureRecognizer         = new TwistGestureRecognizer();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 public void Update()
 {
     if (canManipulate)
     {
         TapGestureRecognizer.Update();
         DragGestureRecognizer.Update();
         PinchGestureRecognizer.Update();
         TwoFingerDragGestureRecognizer.Update();
         TwistGestureRecognizer.Update();
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 public void Update()
 {
     if (j == 0)
     {
         DragGestureRecognizer.Update();
         //PinchGestureRecognizer.Update();
         //TwoFingerDragGestureRecognizer.Update();
         TapGestureRecognizer.Update();
         TwistGestureRecognizer.Update();
     }
 }
Ejemplo n.º 7
0
        private void ConnectToRecognizers()
        {
            if (SceneManager.GetActiveScene().name != "ARManipulation")
            {
                Debug.Log("Scene is not ARManipulation. Halt manipulator script");
                return;
            }
            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;
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// The Unity Update() method.
        /// </summary>
        public void Update()
        {
            //If tap was on UI, ignore tap
            if (IsPointerOverUIObject())
            {
                return;
            }

            DragGestureRecognizer.Update();
            PinchGestureRecognizer.Update();
            TwoFingerDragGestureRecognizer.Update();
            TapGestureRecognizer.Update();
            TwistGestureRecognizer.Update();
        }
Ejemplo n.º 9
0
        private void DisconnectFromRecognizers()
        {
            if (ManipulationSystem.Instance == null)
            {
                Debug.LogError("Manipulation system not found in scene.");
                return;

                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;
            }
        }
Ejemplo n.º 10
0
        private void ConnectToRecognizers()
        {
            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;
            //}
        }