Exemplo n.º 1
0
        void Update()
        {
            var rectPosX = _cachedRect.localPosition.x;

            if (Math.Abs(rectPosX) < _epsion)
            {
                SwipingRight(0);
                SwipingLeft(0);
                return;
            }

            var t        = GetCurrentPosition(rectPosX);
            var maxAngle = rectPosX < 0 ? _viewData.MaxInclinationAngle : -_viewData.MaxInclinationAngle;

            UpdateRotation(Vector3.Lerp(Vector3.zero, new Vector3(0f, 0f, maxAngle), t));

            if (rectPosX > 0)
            {
                SwipingRight(t);
                ActionSwipingRight?.Invoke(this, t);
            }
            else if (rectPosX < 0)
            {
                SwipingLeft(t);
                ActionSwipingLeft?.Invoke(this, t);
            }
        }
        void Update()
        {
            if (Math.Abs(cachedRect.localPosition.x) < EPSILON)
            {
                SwipingToRight(0);
                SwipingToLeft(0);
                return;
            }

            var t        = GetCurrentPosition(cachedRect.localPosition.x);
            var maxAngle = cachedRect.localPosition.x < 0 ? MAX_INCLINED_ANGLE : -MAX_INCLINED_ANGLE;

            UpdateRotation(Vector3.Lerp(Vector3.zero, new Vector3(0f, 0f, maxAngle), t));

            if (cachedRect.localPosition.x > 0)
            {
                SwipingToRight(t);
                ActionSwipingRight?.Invoke(this, t);
            }
            else if (cachedRect.localPosition.x < 0)
            {
                SwipingToLeft(t);
                ActionSwipingLeft?.Invoke(this, t);
            }
        }