コード例 #1
0
    public void ListenForMultiTapsOnCollider(OverlapPointDelegate overlapPoint, int tapCount, float maxTime, HandleTouchInfoDelegate handler)
    {
        int count = 0;

        TouchInfo[] taps = new TouchInfo[tapCount];

        ListenForTouches(TouchAreaHandlerSimple(overlapPoint, (touch) =>
        {
            while (touch.m_startTime - taps[0].m_startTime > maxTime)
            {
                for (int i = 1; i < count; i++)
                {
                    taps[i - 1] = taps[i];
                }
            }

            if (count < tapCount - 1)
            {
                taps[count] = touch;
                count++;
            }
            else
            {
                count = 0;
                handler(touch);
            }
        }));
    }
コード例 #2
0
 private static HandleTouchInfoDelegate TouchAreaHandlerSimple(OverlapPointDelegate overlapPoint, HandleTouchInfoDelegate handler, Camera camera = null)
 {
     return(touch =>
     {
         bool overlap = overlapPoint(touch.WorldPosition(camera));
         if (overlap)
         {
             handler(touch);
         }
     });
 }
コード例 #3
0
    private static HandleTouchInfoDelegate TouchAreaHandlerWithEvents(OverlapPointDelegate overlapPoint, HandleTouchEventDelegate handler, Camera camera = null)
    {
        return(touch =>
        {
            bool overlap = overlapPoint(touch.WorldPosition(camera));
            bool overlapLastFrame = overlapPoint(touch.LastWorldPosition(camera));

            if (overlap && overlapLastFrame)
            {
                handler(touch, ETouchEventType.IN);
            }
            if (overlap && !overlapLastFrame)
            {
                handler(touch, ETouchEventType.ENTER);
            }
            if (!overlap && overlapLastFrame)
            {
                handler(touch, ETouchEventType.EXIT);
            }
        });
    }
コード例 #4
0
 public void ListenForTouchesOnOverlapSimple(OverlapPointDelegate overlapPoint, HandleTouchInfoDelegate handler, Camera camera = null)
 {
     ListenForTouches(TouchAreaHandlerSimple(overlapPoint, handler, camera));
 }
コード例 #5
0
 public void ListenForTouchesOnOverlapWithEvents(OverlapPointDelegate overlapPoint, HandleTouchEventDelegate handler, Camera camera = null)
 {
     ListenForTouches(TouchAreaHandlerWithEvents(overlapPoint, handler, camera));
 }