protected virtual void LateUpdate()
        {
            // Get the fingers we want to use
            var fingers = LeanTouch.GetFingers(IgnoreGuiFingers, RequiredFingerCount);

            // Get the required camera
            var camera = GetComponent <Camera>();

            // 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;

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

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

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

            // Update remainingDelta with the dampened value
            RemainingDelta = newDelta;
        }
示例#2
0
        protected virtual void LateUpdate()
        {
            if (Input.touchCount == 2)
            {
                // 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;
            }
        }
示例#3
0
        protected virtual void LateUpdate()
        {
            // Make sure the camera exists
            if (LeanTouch.GetCamera(ref Camera, gameObject) == true)
            {
                //Busca as informações da Controller do Level.
                LevelController lvl        = (LevelController)gameController.GetComponent("LevelController");
                float           camPosDown = Camera.main.ViewportToWorldPoint(new Vector3(0, 0, Camera.main.nearClipPlane)).y;
                float           camPosUp   = Camera.main.ViewportToWorldPoint(new Vector3(1, 1, Camera.main.nearClipPlane)).y;

                // 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);

                if (camPosDown < lvl.MaxCamPosDown)
                {
                    transform.position -= new Vector3(0, camPosDown - lvl.MaxCamPosDown, 0);
                }
                else if (camPosUp > lvl.MaxCamPosUp)
                {
                    transform.position += new Vector3(0, lvl.MaxCamPosUp - camPosUp, 0);
                }
                else if (((camPosDown > lvl.MaxCamPosDown) && worldDelta.y > 0) || ((camPosUp < lvl.MaxCamPosUp) && worldDelta.y < 0))
                {
                    // Pan the camera, on Y, based on the world delta
                    Vector3 move = new Vector3(0, worldDelta.y * Sensitivity, 0);
                    transform.position -= move;
                }
            }
        }
示例#4
0
        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
            transform.position -= worldDelta;
        }
示例#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, RequiredFingerCount);

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

                // Pan the camera based on the world delta
                transform.position -= worldDelta * Sensitivity;
            }
        }
示例#6
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);
            }
        }
示例#7
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;
            }
        }
示例#8
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;
            }
        }