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); } })); }
private static HandleTouchInfoDelegate TouchAreaHandlerSimple(OverlapPointDelegate overlapPoint, HandleTouchInfoDelegate handler, Camera camera = null) { return(touch => { bool overlap = overlapPoint(touch.WorldPosition(camera)); if (overlap) { handler(touch); } }); }
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); } }); }
public void ListenForTouchesOnOverlapSimple(OverlapPointDelegate overlapPoint, HandleTouchInfoDelegate handler, Camera camera = null) { ListenForTouches(TouchAreaHandlerSimple(overlapPoint, handler, camera)); }
public void ListenForTouchesOnOverlapWithEvents(OverlapPointDelegate overlapPoint, HandleTouchEventDelegate handler, Camera camera = null) { ListenForTouches(TouchAreaHandlerWithEvents(overlapPoint, handler, camera)); }