Пример #1
0
    //Checking and calling respective delegate events
    void SwipeInputs()
    {
        if (swipeManager.SwipeUp && canSwipe)
        {
            canSwipe = false;

            //Calling delegate event
            if (OnSwipeUp != null)
            {
                OnSwipeUp.Invoke();
            }
        }
        else if (swipeManager.SwipeRight && canSwipe)
        {
            canSwipe = false;

            //Calling delegate event
            if (OnSwipeRight != null)
            {
                OnSwipeRight.Invoke();
            }
        }
        else if (swipeManager.SwipeDown && canSwipe)
        {
            canSwipe = false;

            //Calling delegate event
            if (OnSwipeDown != null)
            {
                OnSwipeDown.Invoke();
            }
        }
        else if (swipeManager.SwipeLeft && canSwipe)
        {
            canSwipe = false;

            //Calling delegate event
            if (OnSwipeLeft != null)
            {
                OnSwipeLeft.Invoke();
            }
        }
        else if (swipeManager.Tap)
        {
            //Calling delegate event
            if (OnSingleTap != null)
            {
                OnSingleTap.Invoke();
            }
        }
        else if (swipeManager.DoubleTap)
        {
            //Calling delegate event
            if (OnDoubleTap != null)
            {
                OnDoubleTap.Invoke();
            }
        }
    }
Пример #2
0
    //We trigger single tap
    private void TriggerSingleTap() //! Called by Function name with string reference
    {
        doubleTapInitialized = false;

        if (canTap)
        {
            //Calling delegate event
            if (OnSingleTap != null)
            {
                OnSingleTap.Invoke();
            }
        }
    }
Пример #3
0
 private void UpdateMobile()
 {
     for (var i = 0; i < Input.touchCount; i++)
     {
         if (Input.GetTouch(i).phase == TouchPhase.Began)
         {
             if (Input.GetTouch(i).tapCount == 2)
             {
                 OnDoubleTap?.Invoke();
             }
             if (Input.GetTouch(i).tapCount == 1)
             {
                 OnSingleTap?.Invoke();
             }
         }
     }
 }
Пример #4
0
 private void UpdateEditor()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (Time.time < _tapTimer + TapThreshold)
         {
             OnDoubleTap?.Invoke();
             _tap = false;
             return;
         }
         _tap      = true;
         _tapTimer = Time.time;
     }
     if (_tap && Time.time > _tapTimer + TapThreshold)
     {
         _tap = false;
         OnSingleTap?.Invoke();
     }
 }
Пример #5
0
        private void DetectTapGestures()
        {
            TouchManipulationInfo[] infos = new TouchManipulationInfo[_touchDictionary.Count];
            _touchDictionary.Values.CopyTo(infos, 0);
            if (infos.Length != 1)
            {
                return;
            }
            SKPoint point = infos[0].PreviousPoint;

            if (infos[0].MoveCounter > MaxTapMoveCounter)
            {
                return;
            }
            var tapEventArgs = new TapEventArgs(point);

            var now         = DateTime.Now;
            var lastTapTime = LastTapTime;

            LastTapTime = now;

            OnTap?.Invoke(this, tapEventArgs);
            if (now - lastTapTime < DoubleTapDelay)
            {
                OnDoubleTap?.Invoke(this, tapEventArgs);
                LastDoubleTapTime = now;
                LastTapTime       = DateTime.MinValue; //Reset double tap timer
            }
            else
            {
                _timer = new Timer(_ =>
                {
                    if (DateTime.Now - LastDoubleTapTime < DoubleTapDelay)
                    {
                        return;
                    }
                    OnSingleTap?.Invoke(this, tapEventArgs);
                }, null, DoubleTapDelay.Milliseconds, Timeout.Infinite);
            }
        }