Beispiel #1
0
 void Update()
 {
     if (!IsTouching)
     {
         return;
     }
     OnTouching.Invoke(TouchGetter.GetTouchPositon());
 }
        void OnTouching(Vector2 touchPosition)
        {
            //移動量の計算
            touchPosition    = TouchGetter.GetTouchPositon();
            DeltaPosition    = (touchPosition - oldTouchPosition) * screenSizeRate;
            oldTouchPosition = touchPosition;

            //スワイプ中にCanTouchがfalseになった
            if (isStartTouch && !CanTouch)
            {
                isStartTouch = false;
                if (onTouchEnd != null)
                {
                    onTouchEnd.Invoke(oldTouchPosition);
                }
            }

            //操作受け中ではなかった
            if (!isStartTouch || !CanTouch)
            {
                return;
            }

            if (onTouching != null)
            {
                onTouching.Invoke(touchPosition);
            }

            inputBuffer[currentBufIndex] = DeltaPosition;
            currentBufIndex++;
            if (currentBufIndex >= bufferSize)
            {
                currentBufIndex = 0;
            }


            if (swipePower < swipePowerBoder)
            {
                touchTime  += Time.deltaTime;
                swipeValue += DeltaPosition;
                swipePower  = swipeValue.magnitude;
            }
            else
            {
                Vector2 sum = Vector2.zero;
                for (int i = 0; i < bufferSize; i++)
                {
                    sum += inputBuffer[i];
                }

                DeltaPosition = sum / bufferSize;
                if (onSwipe != null)
                {
                    onSwipe.Invoke(DeltaPosition);
                }
            }
        }
Beispiel #3
0
        public void OnPointerUp(PointerEventData eventData)
        {
            if (!IsTouching)
            {
                return;
            }

            IsTouching = false;
            OnTouchEnd.Invoke(TouchGetter.GetTouchPositon());
        }
        void OnTouchStart(Vector2 touchPosition)
        {
            isStartTouch = CanTouch;
            if (!isStartTouch)
            {
                return;
            }

            DeltaPosition    = Vector2.zero;
            swipePower       = 0.0f;
            swipeValue       = Vector2.zero;
            touchTime        = 0.0f;
            oldTouchPosition = TouchGetter.GetTouchPositon();

            if (onTouchStart != null)
            {
                onTouchStart.Invoke(touchPosition);
            }
        }
Beispiel #5
0
        void OnTouching(Vector2 touchPosition)
        {
            //移動量の計算
            touchPosition    = TouchGetter.GetTouchPositon();
            DeltaPosition    = (touchPosition - oldTouchPosition) * screenSizeRate;
            oldTouchPosition = touchPosition;

            //スワイプ中にCanTouchがfalseになった
            if (isStartTouch && !CanTouch)
            {
                isStartTouch = false;
                if (onTouchEnd != null)
                {
                    onTouchEnd.Invoke(oldTouchPosition);
                }
            }

            //操作受け中ではなかった
            if (!isStartTouch || !CanTouch)
            {
                return;
            }

            if (swipePower < swipePowerBoder)
            {
                touchTime  += Time.deltaTime;
                swipeValue += DeltaPosition;
                swipePower  = swipeValue.magnitude;
            }
            else
            {
                if (onSwipe != null)
                {
                    onSwipe.Invoke(DeltaPosition);
                }
            }
        }
Beispiel #6
0
 public void OnPointerDown(PointerEventData eventData)
 {
     IsTouching = true;
     OnTouchStart.Invoke(TouchGetter.GetTouchPositon());
 }