/// <summary>
 /// Helper function for creating one finger gestures when a touch begins.
 /// </summary>
 /// <typeparam name="createGestureFunction">Function to be executed to create the
 /// gesture.</param>
 protected internal void TryCreateOneFingerGestureOnTouchBegan(
     Func <Touch, T> createGestureFunction)
 {
     for (int i = 0; i < Input.touches.Length; i++)
     {
         Touch touch = Input.touches[i];
         if (touch.phase == TouchPhase.Began &&
             !GestureTouchesUtility.IsFingerIdRetained(touch.fingerId) &&
             !GestureTouchesUtility.IsTouchOffScreenEdge(touch))
         {
             T gesture = createGestureFunction(touch);
             gesture.onStart    += OnStart;
             gesture.onFinished += OnFinished;
             m_Gestures.Add(gesture);
         }
     }
 }
        private void TryCreateGestureTwoFingerGestureOnTouchBeganForTouchIndex(
            int touchIndex,
            Func <Touch, Touch, T> createGestureFunction)
        {
            if (Input.touches[touchIndex].phase != TouchPhase.Began)
            {
                return;
            }

            Touch touch = Input.touches[touchIndex];

            if (GestureTouchesUtility.IsFingerIdRetained(touch.fingerId) ||
                GestureTouchesUtility.IsTouchOffScreenEdge(touch))
            {
                return;
            }

            for (int i = 0; i < Input.touches.Length; i++)
            {
                if (i == touchIndex)
                {
                    continue;
                }

                // Prevents the same two touches from creating two gestures if both touches began on
                // the same frame.
                if (i < touchIndex && Input.touches[i].phase == TouchPhase.Began)
                {
                    continue;
                }

                Touch otherTouch = Input.touches[i];
                if (GestureTouchesUtility.IsFingerIdRetained(otherTouch.fingerId) ||
                    GestureTouchesUtility.IsTouchOffScreenEdge(otherTouch))
                {
                    continue;
                }

                T gesture = createGestureFunction(touch, otherTouch);
                gesture.onStart    += OnStart;
                gesture.onFinished += OnFinished;
                m_Gestures.Add(gesture);
            }
        }