示例#1
0
        private bool GetMouseInput()
        {
            if (Input.GetMouseButtonDown(0))
            {
                _startPressPos = Input.mousePosition;
                _currPressPos  = _startPressPos;
                _isSwipeEnded  = false;
                TouchBegan?.Invoke(_startPressPos);
            }
            else if (Input.GetMouseButtonUp(0))
            {
                _endPressPos  = Input.mousePosition;
                _isSwipeEnded = true;
                TouchEnd?.Invoke(_endPressPos);

                return(true);
            }
            else if (Input.GetMouseButton(0))
            {
                _lastPressPos = _currPressPos;
                _currPressPos = Input.mousePosition;
                PointerDown?.Invoke(_currPressPos);

                return(true);
            }

            return(false);
        }
示例#2
0
        public static Task <bool> JsTouchEnd(TouchEvent @event)
        {
            if (@event is object)
            {
                TouchEnd?.Invoke(null, @event);
            }

            return(Task.FromResult(true));
        }
示例#3
0
        private void SetEvent(Touch input)
        {
            firstTouchTime += input.deltaTime;

            OneTouchEvents?.Invoke(input.position, input.deltaPosition);

            if (input.phase == TouchPhase.Ended)
            {
                TouchEnd?.Invoke(input.deltaPosition, firstTouchTime);

                if (firstTouchTime > 0.1 && firstTouchTime < 0.3)
                {
                    OneFingerTap?.Invoke(input.position);
                }

                firstTouchTime  = 0;
                secondTouchTime = 0;
            }
        }
示例#4
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);
                }
            }
        }
示例#5
0
        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;
            }
        }
示例#6
0
        private void SetEvent(Touch input1, Touch input2)
        {
            TwoTouchEvents?.Invoke(input1.position, input1.deltaPosition, input2.position, input2.deltaPosition);

            firstTouchTime  += input1.deltaTime;
            secondTouchTime += input2.deltaTime;

            if (input1.phase == TouchPhase.Ended && input2.phase == TouchPhase.Ended)
            {
                TouchEnd?.Invoke(input1.deltaPosition, firstTouchTime);

                if ((firstTouchTime > 0.1 && firstTouchTime < 0.3) ||
                    (secondTouchTime > 0.1 && secondTouchTime < 0.3))
                {
                    TwoFingerTap?.Invoke(input1.position);
                }

                firstTouchTime  = 0;
                secondTouchTime = 0;
            }
        }
示例#7
0
        private bool GetTouchInput()
        {
            if (Input.touches.Length > 0)
            {
                var touch = Input.GetTouch(0);
                switch (touch.phase)
                {
                case TouchPhase.Began:
                    _startPressPos = touch.position;
                    _currPressPos  = _startPressPos;
                    _isSwipeEnded  = false;
                    TouchBegan?.Invoke(touch.position);

                    break;

                case TouchPhase.Ended:
                case TouchPhase.Canceled:
                    _endPressPos  = touch.position;
                    _isSwipeEnded = true;

                    TouchEnd?.Invoke(touch.position);

                    return(true);

                case TouchPhase.Moved:
                case TouchPhase.Stationary:
                    _lastPressPos = _currPressPos;
                    _currPressPos = touch.position;

                    PointerDown?.Invoke(touch.position);

                    return(true);
                }
            }

            return(false);
        }
示例#8
0
 public virtual void OnTouchEnd(TouchEventArgs ev)
 {
     TouchEnd?.Invoke(this, ev);
 }
 internal void OnTouchEnd(Model model, TouchEventArgs e) => TouchEnd?.Invoke(model, e);
 public virtual void OnTouchEnd()
 {
     TouchEnd?.Invoke(this, EventArgs.Empty);
 }
示例#11
0
 private void OnTouchEnd(Vector2 position)
 {
     TouchEnd?.Invoke(position);
 }