Zoom the camera in a 2D game?

Want to make approach and separation of the substrate in a 2D game. The camera is in orthogonal mode, aimed at the sprite of the substrate (using 2d toolkit), the sprite in its original size without scaling. The minimum value of the zoom will be such a size camera, with which the sprite will fill the screen by cutting the height. Maximum — hardcode or factor in a percentage of the minimum.

I can not understand how to calculate the size value to minimum zoom when you know the dimensions of the screen and the substrate.

Should I change the view port of the camera for different relations of the sides of the screen?
October 3rd 19 at 03:46
2 answers
October 3rd 19 at 03:48
He answered his own question.
minCameraSize = ((backSprite.renderer.bounds.size.x) / backCamera.aspect) / 2;
backCamera.orthographicSize = minCameraSize;
October 3rd 19 at 03:50

Find more questions by tags Unity Game Engine