Exemplo n.º 1
0
        public static bool TryGetPinchRatio(List <LeanFinger> fingers, Vector2 center, Vector2 lastCenter, ref float ratio, float wheelSensitivity = 0.0f)
        {
            var distance     = LeanGesture.GetScreenDistance(fingers, center);
            var lastDistance = LeanGesture.GetLastScreenDistance(fingers, lastCenter);

            if (distance > 0.0f)
            {
                ratio = lastDistance / distance;

                return(true);
            }

            if (wheelSensitivity != 0.0f)
            {
                var scroll = Input.mouseScrollDelta.y;

                if (scroll > 0.0f)
                {
                    ratio = 1.0f + wheelSensitivity; return(true);
                }

                if (scroll < 0.0f)
                {
                    ratio = 1.0f - wheelSensitivity; return(true);
                }
            }

            return(false);
        }