Example #1
0
        public static Task <bool> JsTouchStart(TouchEvent @event)
        {
            if (@event is object)
            {
                TouchStart?.Invoke(null, @event);
            }

            return(Task.FromResult(true));
        }
Example #2
0
        private void Update()
        {
            bool touchInProgress = currentTouchPhase == TouchPhase.Moved || currentTouchPhase == TouchPhase.Stationary;

            touchPosition = Input.mousePosition;
            if (touchInProgress || boundRect.Contains(touchPosition.Value))
            {
                if (Input.GetMouseButtonDown(0))
                {
                    currentTouchPhase = TouchPhase.Began;
                    TouchStart?.Invoke(currentTouchPhase, touchPosition.Value);
                }

                if (Input.GetMouseButton(0))
                {
                    if (!lastTouchPosition.HasValue)
                    {
                        lastTouchPosition = touchPosition.Value;
                    }

                    TouchDelta        = (touchPosition.Value - lastTouchPosition.Value) / scaleFactor;
                    lastTouchPosition = touchPosition.Value;

                    if (TouchDelta.magnitude > 0)
                    {
                        currentTouchPhase = TouchPhase.Moved;
                        TouchMove?.Invoke(currentTouchPhase, TouchDelta);
                    }
                    else
                    {
                        currentTouchPhase = TouchPhase.Stationary;
                        TouchStationary?.Invoke(currentTouchPhase, touchPosition.Value);
                    }
                }

                if (Input.GetMouseButtonUp(0))
                {
                    lastTouchPosition = null;
                    currentTouchPhase = TouchPhase.Ended;
                    TouchEnd?.Invoke(currentTouchPhase, touchPosition.Value);
                }
            }
        }
        private void FireTouchEvent(Touch i_touch, Vector2 i_startPos = default)
        {
            switch (i_touch.phase)
            {
            case TouchPhase.Began:
                TouchStart?.Invoke(i_touch, i_touch.position);
                break;

            case TouchPhase.Moved:
                TouchMove?.Invoke(i_touch, i_touch.position, i_touch.position - i_startPos);
                break;

            case TouchPhase.Ended:
                TouchEnd?.Invoke(i_touch);
                startPosByTouch.Remove(i_touch);
                allTouches.Remove(i_touch);
                break;
            }
        }
 public override void OnLevelEnd()
 {
     if (TouchStart != null)
     {
         foreach (TouchStartHandler d in TouchStart.GetInvocationList())
         {
             TouchStart -= (TouchStartHandler)d;
         }
     }
     if (TouchMove != null)
     {
         foreach (TouchMoveHandler d in TouchMove.GetInvocationList())
         {
             TouchMove -= (TouchMoveHandler)d;
         }
     }
     if (TouchEnd != null)
     {
         foreach (TouchEndHandler d in TouchEnd.GetInvocationList())
         {
             TouchEnd -= (TouchEndHandler)d;
         }
     }
 }
 internal void OnTouchStart(Model model, TouchEventArgs e) => TouchStart?.Invoke(model, e);
Example #6
0
 private void OnTouchStart(Vector2 position)
 {
     TouchStart?.Invoke(position);
 }