Esempio n. 1
0
 protected void RaiseGestureStopEvent()
 {
     if (GestureStop != null)
     {
         GestureStop.Invoke(new GestureEventArgs(this));
     }
 }
Esempio n. 2
0
 protected void RaiseGestureActiveEvent()
 {
     if (GestureActive != null)
     {
         GestureActive.Invoke(new GestureEventArgs(this));
     }
 }
Esempio n. 3
0
    private void Process()
    {
        Vector2 move = end - start;

        if (Mathf.Abs(move.x) > Mathf.Abs(move.y))
        {
            if (move.x > 0)
            {
                touchRight.Invoke();
            }
            else
            {
                touchLeft.Invoke();
            }
        }
        else
        {
            if (move.y > 0)
            {
                touchUp.Invoke();
            }
            else
            {
                touchDown.Invoke();
            }
        }
    }
Esempio n. 4
0
 /// <inheritdoc />
 protected override void onRecognized()
 {
     base.onRecognized();
     if (pressedInvoker != null)
     {
         pressedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     }
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(PRESS_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
     if (UseUnityEvents)
     {
         OnPress.Invoke(this);
     }
 }
Esempio n. 5
0
 /// <inheritdoc />
 protected override void onBegan()
 {
     base.onBegan();
     if (transformStartedInvoker != null)
     {
         transformStartedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
     }
     if (UseSendMessage && SendMessageTarget != null)
     {
         SendMessageTarget.SendMessage(TRANSFORM_START_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
     }
     if (UseUnityEvents)
     {
         OnTransformStart.Invoke(this);
     }
 }
Esempio n. 6
0
        /// <inheritdoc />
        protected override void onRecognized()
        {
            base.onRecognized();

            if (transformCompletedInvoker != null)
            {
                transformCompletedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TRANSFORM_COMPLETE_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
            }
            if (UseUnityEvents)
            {
                OnTransformComplete.Invoke(this);
            }
        }
Esempio n. 7
0
        /// <inheritdoc />
        protected override void onRecognized()
        {
            base.onRecognized();

            StopCoroutine("wait");
            if (tappedInvoker != null)
            {
                tappedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TAP_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
            }
            if (UseUnityEvents)
            {
                OnTap.Invoke(this);
            }
        }
Esempio n. 8
0
        /// <inheritdoc />
        protected override void onChanged()
        {
            base.onChanged();

            targetPositionOverridden = false;

            if (transformedInvoker != null)
            {
                transformedInvoker.InvokeHandleExceptions(this, EventArgs.Empty);
            }
            if (UseSendMessage && SendMessageTarget != null)
            {
                SendMessageTarget.SendMessage(TRANSFORM_MESSAGE, this, SendMessageOptions.DontRequireReceiver);
            }
            if (UseUnityEvents)
            {
                OnTransform.Invoke(this);
            }
        }
Esempio n. 9
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            OnEsc?.Invoke(KeyCode.Escape);
        }

        if (Input.touchCount == 0)
        {
            _isMoving = false;
        }
        else
        {
            foreach (var touch in Input.touches)
            {
                //register new input
                if (touch.phase == TouchPhase.Began)
                {
                    //prevent UI taps
                    if (EventSystem.current.IsPointerOverGameObject(touch.fingerId))
                    {
                        continue;
                    }
                    //prevent taps while drag
                    if (_isMoving)
                    {
                        continue;
                    }
                    GestureData gestureData = new GestureData();
                    gestureData.fingerId      = touch.fingerId;
                    gestureData.Type          = GestureType.None;
                    gestureData.startPosition = touch.position;
                    gestureData.endPosition   = touch.position;
                    gestureData.deltaPosition = Vector2.zero;
                    gestureData.time          = 0;
                    _gestures.Add(gestureData);
                    ++count;
                }
                else //process existing input
                {
                    int index = FindTouchIndexById(touch.fingerId);
                    if (index == -1)
                    {
                        continue;
                    }
                    _gestures[index].endPosition   = touch.position;
                    _gestures[index].deltaPosition = touch.deltaPosition;
                    _gestures[index].time         += touch.deltaTime;

                    float distance = (_gestures[index].endPosition - _gestures[index].startPosition).magnitude;
                    if (touch.phase == TouchPhase.Moved)
                    {
                        if (distance > minDistance || _isMoving)
                        {
                            _isMoving = true;
                            if (_gestures[index].time > maxTime)
                            {
                                _gestures[index].Type = GestureType.Drag;
                                OnDrag.Invoke(_gestures[index]);
                            }
                        }
                    }
                    else if (touch.phase == TouchPhase.Ended)
                    {
                        if (distance < minDistance && _gestures[index].time < maxTime)
                        {
                            OnTap.Invoke(_gestures[index]);
                        }
                        else if (distance > minDistance && _gestures[index].time < maxTime)
                        {
                            _isMoving = false;
                            OnSwipe.Invoke(_gestures[index]);
                        }
                        else if (distance > minDistance && _gestures[index].time > maxTime)
                        {
                            _isMoving = false;
                            OnDrag.Invoke(_gestures[index]);
                        }
                        _gestures.RemoveAt(index);
                        --count;
                    }
                } //end proccess existing input
            }
        }
    }
Esempio n. 10
0
 public void Trigger(GestureSample gesture)
 {
     GestureEvent?.Invoke(gesture);
 }
Esempio n. 11
0
 void SensorTrigger(GestureType type)
 {
     m_OnSensorTriggered?.Invoke(new GestureEventData(type));
 }
Esempio n. 12
0
 public override void DeactivateGesture(JSONObject args)
 {
     OnStopGesture.Invoke(args);
 }
Esempio n. 13
0
 public override void ActivateGesture(JSONObject args)
 {
     OnStartGesture.Invoke(args);
 }