- Home /
Changing Orthographic size according to resolution
I know this question was already asked, but I didn't find the correct answer for my situation, so be patient with me please :(
I'm making a 2D puzzle game with a board, and I would like to set up my Orthographic camera size according to the resolution, aspect ratio, and board size.
The objective is to get a full screen board with all mobile devices.
Can someone help me?
Answer by robertbu · Apr 18, 2014 at 06:51 PM
Assuming a square board, centered on the camera of 'boardSize' the code would be:
if (Screen.width < Screen.height) {
Camera.main.orthographicSize = boardSize / 2 * Screen.height / Screen.width;
}
You only have to make a change if the width is narrower than the height. For a given orthographicSize, the camera will see the same height in world units no matter what the resolution.
Your answer
Follow this Question
Related Questions
Unity does not change the size of the window 0 Answers
GUI To change with screen resolution? 2 Answers
Camera view different screen sizes? 0 Answers
How do i remove the launcher that pops up when running the game? 1 Answer
Photoshop project size question. 3 Answers