Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount > 0)
        {
            _touch       = Input.GetTouch(0);
            _touchTimer += Time.deltaTime;
            switch (_touch.phase)
            {
            case TouchPhase.Ended:
                if (_touch.tapCount >= 2)
                {
                    StopAllCoroutines();
                    if (OnDoubleClick != null)
                    {
                        OnDoubleClick.Invoke(_touch);
                        Debug.Log("Working");
                    }
                }
                else if (_touchTimer < LongPressThreshold)
                {
                    StartCoroutine(CheckSingleClick());
                }
                else if (_touchTimer > LongPressThreshold)
                {
                    StopAllCoroutines();
                    OnRelease.Invoke(_touch);
                }

                break;

            case TouchPhase.Moved:
                if (_touchTimer > LongPressThreshold)
                {
                    if (OnLongPressing != null)
                    {
                        OnLongPressing.Invoke(_touch);
                    }
                }
                break;

            case TouchPhase.Stationary:
                if (_touchTimer > LongPressThreshold)
                {
                    if (OnLongPressing != null)
                    {
                        OnLongPressing.Invoke(_touch);
                    }
                }
                break;

            default:
                break;
            }
        }
        else
        {
            _touchTimer = 0;
        }
    }
Esempio n. 2
0
 public void setOnLongPressing(OnLongPressing callback)
 {
     mOnLongPressing = callback;
 }