コード例 #1
0
ファイル: LeanSideCamera3D.cs プロジェクト: lickey10/LavaRun
        protected virtual void LateUpdate()
        {
            // Does the main camera exist?
            if (Camera.main != null)
            {
                // Get the world delta of all the fingers
                var worldDelta = LeanTouch.GetDeltaWorldPosition(Distance);                 // Distance doesn't matter with an orthographic camera

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

                // Make sure the pinch scale is valid
                if (LeanTouch.PinchScale > 0.0f)
                {
                    // Store the old FOV in a temp variable
                    var fieldOfView = Camera.main.fieldOfView;

                    // Scale the FOV based on the pinch scale
                    fieldOfView /= LeanTouch.PinchScale;

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

                    // Set the new FOV
                    Camera.main.fieldOfView = fieldOfView;
                }
            }
        }
コード例 #2
0
ファイル: LeanSideCamera2D.cs プロジェクト: lickey10/LavaRun
        protected virtual void LateUpdate()
        {
            // Does the main camera exist?
            if (Camera.main != null)
            {
                // Get the world delta of all the fingers
                var worldDelta = LeanTouch.GetDeltaWorldPosition(1.0f);                 // Distance doesn't matter with an orthographic camera

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

                // Make sure the pinch scale is valid
                if (LeanTouch.PinchScale > 0.0f)
                {
                    // Store the old size in a temp variable
                    var orthographicSize = Camera.main.orthographicSize;

                    // Scale the size based on the pinch scale
                    orthographicSize /= LeanTouch.PinchScale;

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

                    // Set the new size
                    Camera.main.orthographicSize = orthographicSize;
                }
            }
        }