示例#1
0
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 public void Update()
 {
     DragGestureRecognizer.Update();
     PinchGestureRecognizer.Update();
     TwoFingerDragGestureRecognizer.Update();
     TapGestureRecognizer.Update();
     TwistGestureRecognizer.Update();
 }
示例#2
0
 /// <summary>
 /// Constructs a two finger drag 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 TwoFingerDragGesture(TwoFingerDragGestureRecognizer recognizer, Touch touch1, Touch touch2) : base(recognizer)
 {
     FingerId1      = touch1.fingerId;
     StartPosition1 = touch1.position;
     FingerId2      = touch2.fingerId;
     StartPosition2 = touch2.position;
     Position       = (StartPosition1 + StartPosition2) / 2;
 }
示例#3
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();
 }
 /// <summary>
 /// The Unity Update() method.
 /// </summary>
 public void Update()
 {
     if (canManipulate)
     {
         TapGestureRecognizer.Update();
         DragGestureRecognizer.Update();
         PinchGestureRecognizer.Update();
         TwoFingerDragGestureRecognizer.Update();
         TwistGestureRecognizer.Update();
     }
 }
        /// <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 at least one finger is moving.
            if (touch1.deltaPosition == Vector2.zero && touch2.deltaPosition == Vector2.zero)
            {
                return(false);
            }

            Vector2 pos1       = touch1.position;
            float   diff1      = (pos1 - StartPosition1).magnitude;
            Vector2 pos2       = touch2.position;
            float   diff2      = (pos2 - StartPosition2).magnitude;
            float   slopInches = (Recognizer as TwoFingerDragGestureRecognizer).SlopInches;

            if (GestureTouchesUtility.PixelsToInches(diff1) < slopInches ||
                GestureTouchesUtility.PixelsToInches(diff2) < slopInches)
            {
                return(false);
            }

            TwoFingerDragGestureRecognizer recognizer =
                Recognizer as TwoFingerDragGestureRecognizer;

            // Check both fingers move in the same direction.
            float dot =
                Vector3.Dot(touch1.deltaPosition.normalized, touch2.deltaPosition.normalized);

            if (dot < Mathf.Cos(recognizer.AngleThresholdRadians))
            {
                return(false);
            }

            return(true);
        }
示例#6
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;
            }
        }
示例#7
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();
        }
示例#8
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;
            }
        }