コード例 #1
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = Use.GetFingers();

            if (fingers.Count > 1 && onPinch != null)
            {
                switch (Coordinate)
                {
                case CoordinateType.OneBasedScale:
                {
                    var scale = LeanGesture.GetPinchScale(fingers);

                    scale = Mathf.Pow(scale, Multiplier);

                    onPinch.Invoke(scale);
                }
                break;

                case CoordinateType.OneBasedRatio:
                {
                    var ratio = LeanGesture.GetPinchRatio(fingers);

                    ratio = Mathf.Pow(ratio, Multiplier);

                    onPinch.Invoke(ratio);
                }
                break;

                case CoordinateType.ZeroBasedScale:
                {
                    var scale = LeanGesture.GetPinchScale(fingers);

                    scale = (scale - 1.0f) * Multiplier;

                    onPinch.Invoke(scale);
                }
                break;

                case CoordinateType.ZeroBasedRatio:
                {
                    var ratio = LeanGesture.GetPinchRatio(fingers);

                    ratio = (ratio - 1.0f) * Multiplier;

                    onPinch.Invoke(ratio);
                }
                break;

                case CoordinateType.ZeroBasedDistance:
                {
                    var oldDistance = LeanGesture.GetLastScaledDistance(fingers, LeanGesture.GetLastScreenCenter(fingers));
                    var newDistance = LeanGesture.GetScaledDistance(fingers, LeanGesture.GetScreenCenter(fingers));
                    var movement    = (newDistance - oldDistance) * Multiplier;

                    onPinch.Invoke(movement);
                }
                break;
                }
            }
        }