Пример #1
0
        protected virtual void FixedUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            if (fingers.Count > 0)
            {
                var cachedCamera = LeanTouch.GetCamera(Camera, gameObject);

                if (cachedCamera != null)
                {
                    var targetPoint = LeanGesture.GetScreenCenter(fingers);
                    var newPosition = ScreenDepth.Convert(targetPoint, Camera, gameObject);
                    var factor      = LeanTouch.GetDampenFactor(Dampening, Time.fixedDeltaTime);

                    transform.position = Vector3.Lerp(transform.position, newPosition, factor);
                }
            }
        }
Пример #2
0
        protected virtual void LateUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Get the pinch ratio of these fingers
            var pinchRatio = LeanGesture.GetPinchRatio(fingers, WheelSensitivity);

            // Modify the zoom value
            Zoom *= pinchRatio;

            if (ZoomClamp == true)
            {
                Zoom = Mathf.Clamp(Zoom, ZoomMin, ZoomMax);
            }

            // Set the new zoom
            SetZoom(Zoom);
        }
        protected virtual void LateUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Get the pinch ratio of these fingers
            var pinchRatio = LeanGesture.GetPinchRatio(fingers, WheelSensitivity);

            // Perform the translation if this is a relative scale
            if (Relative == true)
            {
                var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                Translate(pinchRatio, pinchScreenCenter);
            }

            // Modify the zoom value
            Zoom *= pinchRatio;

            if (ZoomClamp == true)
            {
                Zoom = Mathf.Clamp(Zoom, ZoomMin, ZoomMax);
            }


            if (fingers.Count > 1)
            {
                op = true;
                Debug.Log("cambio");
            }
            else
            {
                op = false;
                Debug.Log("No cambio");
            }

            // Set the new zoom
            SetZoom(Zoom);

            //Debug.Log(fingers.Count);
            //DisableCollider(fingerTemp);
        }
Пример #4
0
        protected virtual void FixedUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            if (fingers.Count > 0)
            {
                var camera = LeanTouch.GetCamera(Camera, gameObject);

                if (camera != null)
                {
                    var oldPosition = transform.position;
                    var screenPoint = camera.WorldToScreenPoint(oldPosition);
                    var targetPoint = LeanGesture.GetScreenCenter(fingers);
                    var newPosition = camera.ScreenToWorldPoint(new Vector3(targetPoint.x, targetPoint.y, screenPoint.z));
                    var direction   = (Vector2)(newPosition - oldPosition);
                    var velocity    = direction / Time.fixedDeltaTime;

                    // Apply the velocity
                    velocity *= LeanTouch.GetDampenFactor(Dampening, Time.fixedDeltaTime);

                    cachedRigidbody.velocity = velocity;

                    if (Rotation == true && direction != Vector2.zero)
                    {
                        var angle           = Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg;
                        var directionB      = (Vector2)transform.up;
                        var angleB          = Mathf.Atan2(directionB.x, directionB.y) * Mathf.Rad2Deg;
                        var delta           = Mathf.DeltaAngle(angle, angleB);
                        var angularVelocity = delta / Time.fixedDeltaTime;

                        angularVelocity *= LeanTouch.GetDampenFactor(RotationDampening, Time.fixedDeltaTime);

                        cachedRigidbody.angularVelocity = angularVelocity;
                    }
                }
                else
                {
                    Debug.LogError("Failed to find camera. Either tag your cameras MainCamera, or set one in this component.", this);
                }
            }
        }
Пример #5
0
        protected virtual void LateUpdate()
        {
            // Make sure the camera exists
            if (LeanTouch.GetCamera(ref Camera, gameObject) == true)
            {
                // Get the fingers we want to use
                var fingers = LeanTouch.GetFingers(IgnoreGuiFingers);
                if (fingers.Count > 1)
                {
                    ChangeToolOnHand(true);
                }

                // Get the pinch ratio of these fingers
                var pinchRatio = LeanGesture.GetPinchRatio(fingers, WheelSensitivity);

                // Modify the zoom value
                Zoom *= pinchRatio;


                Zoom = Mathf.Clamp(Zoom, ZoomMin, ZoomMax);

                // Get the world delta of all the fingers
                if (fingers.Count > 1)
                {
                    var worldDelta = LeanGesture.GetWorldDelta(fingers, 0, Camera);

                    // Pan the camera based on the world delta
                    var newPos = transform.position - worldDelta * Sensitivity;

                    if (!isSpecialBounds)
                    {
                        bounds = new Vector2(Camera.main.pixelWidth / 100, Camera.main.pixelHeight / 100);
                    }

                    newPos.x           = Mathf.Clamp(newPos.x, -bounds.x, bounds.x);
                    newPos.y           = Mathf.Clamp(newPos.y, -bounds.y, bounds.y);
                    transform.position = newPos;
                }
                // Set the new zoom
                SetZoom(Zoom);
            }
        }
Пример #6
0
        // Update is called once per frame
        void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount,
                                                    RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, 0);

            if (pinchScale > 0.0f)
            {
                var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                Translate(pinchScale, pinchScreenCenter);
            }


            // Perform the scaling
            Scale(transform.localScale * pinchScale);
        }
Пример #7
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate the rotation values based on these fingers
            var twistDegrees = -LeanGesture.GetTwistDegrees(fingers);

            if (Relative == true)
            {
                var twistScreenCenter = LeanGesture.GetScreenCenter(fingers);

                Translate(twistDegrees, twistScreenCenter);
                Rotate(twistDegrees);
            }
            else
            {
                Rotate(twistDegrees);
            }
        }
Пример #8
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate the rotation values based on these fingers
            var twistDegrees = LeanGesture.GetTwistDegrees(fingers);

            // Perform rotation
            //transform.Rotate(Axis, twistDegrees, Space);
            if (GameObject.FindGameObjectsWithTag("Polygon").Length != 0)
            {
                GameObject[] polygon;
                polygon = GameObject.FindGameObjectsWithTag("Polygon");
                foreach (GameObject goPoly in polygon)
                {
                    goPoly.GetComponent <MeshRenderer>().material.SetFloat("_Rotation", twistDegrees);
                }
            }
        }
Пример #9
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate the screenDelta value based on these fingers
            var screenDelta = LeanGesture.GetScreenDelta(fingers);

            if (screenDelta != Vector2.zero)
            {
                // Perform the translation
                if (transform is RectTransform)
                {
                    TranslateUI(screenDelta);
                }
                else
                {
                    Translate(screenDelta);
                }
            }
        }
Пример #10
0
		private void InvokeUp()
		{
			if (onFingersUp != null)
			{
				onFingersUp.Invoke(fingers);
			}

			var screenPosition = LeanGesture.GetScreenCenter(fingers);

			if (onWorldUp != null)
			{
				var position = ScreenDepth.Convert(screenPosition, gameObject);

				onWorldUp.Invoke(position);
			}

			if (onScreenUp != null)
			{
				onScreenUp.Invoke(screenPosition);
			}
		}
Пример #11
0
        protected virtual void Update()
        {
            // pega os dedos que queremos usar
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // calcular o valor screenDelta com base nesses dedos
            var screenDelta = LeanGesture.GetScreenDelta(fingers);

            if (screenDelta != Vector2.zero)
            {
                // realiza a movimentacao
                if (transform is RectTransform)
                {
                    TranslateUI(screenDelta);
                }
                else
                {
                    Translate(screenDelta);
                }
            }
        }
Пример #12
0
        protected virtual void LateUpdate()
        {
            // If camera is null, try and get the main camera, return true if a camera was found
            if (LeanTouch.GetCamera(ref Camera) == true)
            {
                // Get the fingers we want to use
                var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

                // Store the current size/fov in a temp variable
                var current = GetCurrent();

                // Scale the current value based on the pinch ratio
                current *= LeanGesture.GetPinchRatio(fingers, WheelSensitivity);

                // Clamp the current value to min/max values
                current = Mathf.Clamp(current, Minimum, Maximum);

                // Set the new size/fov
                SetCurrent(current);
            }
        }
Пример #13
0
        protected virtual void Update()
        {
            // Store
            var oldPosition = transform.localPosition;

            // Get the fingers we want to use
            var fingers = Use.GetFingers();

            // Calculate the screenDelta value based on these fingers
            var screenDelta = LeanGesture.GetScreenDelta(fingers);

            if (screenDelta != Vector2.zero)
            {
                // Perform the translation
                if (transform is RectTransform)
                {
                    TranslateUI(screenDelta);
                }
                else
                {
                    Translate(screenDelta);
                }
            }

            // Increment
            remainingTranslation  += transform.localPosition - oldPosition;
            remainingTranslation.y = 0;

            // Get t value
            var factor = LeanTouch.GetDampenFactor(Dampening, Time.deltaTime);

            // Dampen remainingDelta
            var newRemainingTranslation = Vector3.Lerp(remainingTranslation, Vector3.zero, factor);

            // Shift this transform by the change in delta
            transform.localPosition = oldPosition + remainingTranslation - newRemainingTranslation;

            // Update remainingDelta with the dampened value
            remainingTranslation = newRemainingTranslation;
        }
Пример #14
0
        protected virtual void LateUpdate()
        {
            // Get the fingers we want to use
            var fingers = Use.GetFingers();

            // Get the last and current screen point of all fingers
            var lastScreenPoint = LeanGesture.GetLastScreenCenter(fingers);
            var screenPoint     = LeanGesture.GetScreenCenter(fingers);

            // Get the world delta of them after conversion
            var worldDelta = ScreenDepth.ConvertDelta(lastScreenPoint, screenPoint, gameObject);

            Debug.Log(worldDelta);

            // Store the current position
            var oldPosition = transform.localPosition;

            // Pan the camera based on the world delta
            transform.position -= worldDelta * Sensitivity;

            // Add to remainingDelta
            remainingDelta += transform.localPosition - oldPosition;

            // Get t value
            var factor = LeanTouch.GetDampenFactor(Dampening, Time.deltaTime);

            // Dampen remainingDelta
            var newRemainingDelta = Vector3.Lerp(remainingDelta, Vector3.zero, factor);

            // Shift this position by the change in delta
            transform.localPosition = oldPosition + remainingDelta - newRemainingDelta;

            if (fingers.Count == 0 && Inertia > 0.0f && Dampening > 0.0f)
            {
                newRemainingDelta = Vector3.Lerp(newRemainingDelta, remainingDelta, Inertia);
            }

            // Update remainingDelta with the dampened value
            remainingDelta = newRemainingDelta;
        }
Пример #15
0
        protected virtual void FixedUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            if (fingers.Count > 0)
            {
                var cachedCamera = LeanTouch.GetCamera(Camera, gameObject);

                if (cachedCamera != null)
                {
                    var oldPosition = transform.position;
                    var targetPoint = LeanGesture.GetScreenCenter(fingers);
                    var newPosition = ScreenDepth.Convert(targetPoint, Camera, gameObject);
                    var direction   = newPosition - oldPosition;
                    var velocity    = direction / Time.fixedDeltaTime;

                    // Apply the velocity
                    velocity *= LeanTouch.GetDampenFactor(Dampening, Time.fixedDeltaTime);

                    cachedRigidbody.velocity = velocity;

                    /*
                     * if (Rotation == true && direction != Vector3.zero)
                     * {
                     *      var angle           = Mathf.Atan2(direction.x, direction.y) * Mathf.Rad2Deg;
                     *      var directionB      = (Vector2)transform.up;
                     *      var angleB          = Mathf.Atan2(directionB.x, directionB.y) * Mathf.Rad2Deg;
                     *      var delta           = Mathf.DeltaAngle(angle, angleB);
                     *      var angularVelocity = delta / Time.fixedDeltaTime;
                     *
                     *      angularVelocity *= LeanTouch.GetDampenFactor(RotationDampening, Time.fixedDeltaTime);
                     *
                     *      //cachedRigidbody.angularVelocity = angularVelocity;
                     * }
                     */
                }
            }
        }
        protected virtual void Update()
        {
            if (body == null)
            {
                body = GetComponent <Rigidbody>();
            }

            if (Selectable.IsSelected == true)
            {
                // Screen position of the transform
                var screenPosition = Camera.main.WorldToScreenPoint(transform.position);

                // Add the deltaPosition
                screenPosition += (Vector3)LeanGesture.GetScreenDelta();

                // Convert back to world space
                transform.position = Camera.main.ScreenToWorldPoint(screenPosition);

                // Reset velocity
                body.velocity = Vector3.zero;
            }
        }
Пример #17
0
        protected virtual void Update()
        {
            if (PartsManager.instance.GetIsDragging())
            {
                return;
            }

            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate the screenDelta value based on these fingers
            var screenDelta = LeanGesture.GetScreenDelta(fingers);

            // Perform the translation
            if (transform is RectTransform)
            {
                TranslateUI(screenDelta);
            }
            else
            {
                Translate(screenDelta);
            }
        }
        protected virtual void LateUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

            // Get the world delta of all the fingers
            var pinch = LeanGesture.GetPinchRatio(fingers, WheelSensitivity);

            // Dolly the camera based on the pinch ratio
            RemainingDelta += Vector - Vector * pinch;

            // The framerate independent damping factor
            var factor = Mathf.Exp(-Dampening * Time.deltaTime);

            // Dampen remainingDelta
            var newDelta = RemainingDelta * factor;

            // Shift this transform by the change in delta
            transform.position += RemainingDelta - newDelta;

            // Update remainingDelta with the dampened value
            RemainingDelta = newDelta;
        }
Пример #19
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            if (fingers.Count > 0)
            {
                // Get twist
                var twist = Angle == AngleType.Degrees ? LeanGesture.GetTwistDegrees(fingers) : LeanGesture.GetTwistRadians(fingers);

                // Ignore?
                if (IgnoreIfStatic == true && twist == 0.0f)
                {
                    return;
                }

                // Call events
                if (OnTwist != null)
                {
                    OnTwist.Invoke(twist);
                }
            }
        }
Пример #20
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = Use.GetFingers();

            if (fingers.Count > 0)
            {
                // Get twist
                var degrees = LeanGesture.GetTwistDegrees(fingers);

                // Ignore?
                if (IgnoreIfStatic == true && degrees == 0.0f)
                {
                    return;
                }

                // Call events
                if (onTwistDegrees != null)
                {
                    onTwistDegrees.Invoke(degrees);
                }
            }
        }
        protected virtual void LateUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

            // Get the world delta of all the fingers
            var worldDelta = LeanGesture.GetWorldDelta(fingers, Distance, Camera);

            // Pan the camera based on the world delta
            RemainingDelta -= worldDelta;

            // The framerate independent damping factor
            var factor = Mathf.Exp(-Dampening * Time.deltaTime);

            // Dampen remainingDelta
            var newDelta = RemainingDelta * factor;

            // Shift this transform by the change in delta
            transform.position += RemainingDelta - newDelta;

            // Update remainingDelta with the dampened value
            RemainingDelta = newDelta;
        }
Пример #22
0
        protected virtual void LateUpdate()
        {
            // Make sure the camera exists
            if (LeanTouch.GetCamera(ref Camera, gameObject) == true)
            {
                // Get the fingers we want to use
                var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

                // Get the pinch ratio of these fingers
                var pinchRatio = LeanGesture.GetPinchRatio(fingers, WheelSensitivity);

                // Modify the zoom value
                Zoom *= pinchRatio;

                if (ZoomClamp == true)
                {
                    Zoom = Mathf.Clamp(Zoom, ZoomMin, ZoomMax);
                }

                // Set the new zoom
                SetZoom(Zoom);
            }
        }
Пример #23
0
        protected virtual void Update()
        {
            // If we require a selectable and it isn't selected, cancel rotation
            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);
            // Calculate the rotation values based on these fingers

            var degrees = LeanGesture.GetTwistDegrees(fingers);

            var center = LeanGesture.GetScreenCenter(fingers);

//			if (fingers.Count > 0) {
//				float x = fingers [0].ScreenPosition.x - fingers [0].StartScreenPosition.x;
//				float y = fingers [0].ScreenPosition.y - fingers [0].StartScreenPosition.y;
//				Debug.Log ("y--------:" + y);
//				Debug.Log ("x--------:" + x);
//				if (y < 0)
//					y = -y;
//				if (x < 0)
//					x = -x;
//				if (x > y) {
//					Debug.Log ("---left right");
//					RotateAxis = new Vector3 (0, -10, 0);
//				} else {
//					Debug.Log ("---up down");
//					RotateAxis = new Vector3 (-10, 0, 0);
//
//				}
//			}
            //Perform the rotation
            Rotate(center, degrees);
        }
Пример #24
0
        protected virtual void LateUpdate()
        {
            // If we require a selectable and it isn't selected, skip
            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                UpdateRotation();

                return;
            }

            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, true, RequiredFingerCount);

            // Get the scaled average movement vector of these fingers
            var drag = LeanGesture.GetScaledDelta(fingers);

            // Get base sensitivity
            var sensitivity = GetSensitivity();

            // Adjust pitch
            Pitch += drag.y * PitchSensitivity * sensitivity;

            if (PitchClamp == true)
            {
                Pitch = Mathf.Clamp(Pitch, PitchMin, PitchMax);
            }

            // Adjust yaw
            Yaw -= drag.x * YawSensitivity * sensitivity;

            if (YawClamp == true)
            {
                Yaw = Mathf.Clamp(Yaw, YawMin, YawMax);
            }

            UpdateRotation();
        }
Пример #25
0
        protected virtual void Update()
        {
            // Get the fingers we want to use
            var fingers = LeanSelectable.GetFingersOrClear(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Calculate pinch scale, and make sure it's valid
            var pinchScale = LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            if (pinchScale > 0.0f)
            {
                // Perform the translation if this is a relative scale
                if (Relative == true)
                {
                    var pinchScreenCenter = LeanGesture.GetScreenCenter(fingers);

                    if (transform is RectTransform)
                    {
                        TranslateUI(pinchScale, pinchScreenCenter);
                    }
                    else
                    {
                        Translate(pinchScale, pinchScreenCenter);
                    }
                }

                if (Demo01Management.instance.active3D == false)
                {
                    // Perform the scaling
                    Scale(transform.localScale * pinchScale);
                }
            }

            if (Input.GetMouseButtonUp(0))
            {
                transform.localScale = ScaleMin;
            }
        }
Пример #26
0
        private void HandleFingerDown(LeanFinger finger)
        {
            if (IgnoreStartedOverGui == true && finger.IsOverGui == true)
            {
                return;
            }

            if (RequiredSelectable != null && RequiredSelectable.IsSelected == false)
            {
                return;
            }

            fingers.Add(finger);

            if (fingers.Count == RequiredCount)
            {
                if (onFingers != null)
                {
                    onFingers.Invoke(fingers);
                }

                var screenPosition = LeanGesture.GetScreenCenter(fingers);

                if (onWorld != null)
                {
                    var worldPosition = ScreenDepth.Convert(screenPosition, gameObject);

                    onWorld.Invoke(worldPosition);
                }

                if (onScreen != null)
                {
                    onScreen.Invoke(screenPosition);
                }
            }
        }
Пример #27
0
        protected virtual void LateUpdate()
        {
            // If camera is null, try and get the main camera, return true if a camera was found
            if (LeanTouch.GetCamera(ref Camera) == true)
            {
                // Get the world delta of all the fingers
                var worldDelta = LeanGesture.GetWorldDelta(Distance);

                // Subtract the delta to the position
                Camera.transform.position -= worldDelta;

                // Store the old FOV in a temp variable
                var fieldOfView = Camera.fieldOfView;

                // Scale the FOV based on the pinch scale
                fieldOfView *= LeanGesture.GetPinchRatio();

                // Clamp the FOV to out min/max values
                fieldOfView = Mathf.Clamp(fieldOfView, FovMin, FovMax);

                // Set the new FOV
                Camera.fieldOfView = fieldOfView;
            }
        }
Пример #28
0
        protected virtual void LateUpdate()
        {
            // If camera is null, try and get the main camera, return true if a camera was found
            if (LeanTouch.GetCamera(ref Camera) == true)
            {
                // Get the world delta of all the fingers
                var worldDelta = LeanGesture.GetWorldDelta(1.0f, Camera);                 // Distance doesn't matter with an orthographic camera

                // Subtract the delta to the position
                Camera.transform.position -= worldDelta;

                // Store the old size in a temp variable
                var orthographicSize = Camera.orthographicSize;

                // Scale the size based on the pinch scale
                orthographicSize *= LeanGesture.GetPinchRatio();

                // Clamp the size to out min/max values
                orthographicSize = Mathf.Clamp(orthographicSize, Minimum, Maximum);

                // Set the new size
                Camera.orthographicSize = orthographicSize;
            }
        }
Пример #29
0
        protected virtual void Update()
        {
            // Get an initial list of fingers
            var fingers = Use.GetFingers();

            if (fingers.Count > 0)
            {
                // Get delta
                var screenFrom = LeanGesture.GetLastScreenCenter(fingers);
                var screenTo   = LeanGesture.GetScreenCenter(fingers);
                var finalDelta = screenTo - screenFrom;

                if (IgnoreIfStatic == true && finalDelta.sqrMagnitude <= 0.0f)
                {
                    return;
                }

                if (onFingers != null)
                {
                    onFingers.Invoke(fingers);
                }

                switch (Coordinate)
                {
                case CoordinateType.ScaledPixels:     finalDelta *= LeanTouch.ScalingFactor; break;

                case CoordinateType.ScreenPercentage: finalDelta *= LeanTouch.ScreenFactor;  break;
                }

                finalDelta *= Multiplier;

                if (onDelta != null)
                {
                    onDelta.Invoke(finalDelta);
                }

                if (onDistance != null)
                {
                    onDistance.Invoke(finalDelta.magnitude);
                }

                var worldFrom = ScreenDepth.Convert(screenFrom, gameObject);
                var worldTo   = ScreenDepth.Convert(screenTo, gameObject);

                if (onWorldFrom != null)
                {
                    onWorldFrom.Invoke(worldFrom);
                }

                if (onWorldTo != null)
                {
                    onWorldTo.Invoke(worldTo);
                }

                if (onWorldDelta != null)
                {
                    onWorldDelta.Invoke(worldTo - worldFrom);
                }

                if (onWorldFromTo != null)
                {
                    onWorldFromTo.Invoke(worldFrom, worldTo);
                }
            }
        }
Пример #30
0
        protected virtual void Update()
        {
            // Get fingers
            var fingers = LeanSelectable.GetFingers(IgnoreStartedOverGui, IgnoreIsOverGui, RequiredFingerCount, RequiredSelectable);

            // Get pinch
            var pinch = Scale == ScaleType.PinchRatio == true?LeanGesture.GetPinchRatio(fingers, WheelSensitivity) : LeanGesture.GetPinchScale(fingers, WheelSensitivity);

            // Ignore?
            if (pinch == 1.0f)
            {
                return;
            }

            // This gives you a 0 based pinch value, allowing usage with translation and rotation
            if (Scale == ScaleType.PinchShift)
            {
                pinch -= 1.0f;
            }

            // Call events
            if (OnPinch != null)
            {
                OnPinch.Invoke(pinch);
            }
        }