I’m working on a 2D game right now, where it is very important that you have the same picture on your screen even with different screen ratios. Lately is stumbled upon the problem that Unity simply crops out everything that does not fit on the screen, so i tried to figure out a way to solve this problem. The free aspect of the camera is nearly 22 / 9, so the script simply compares the resolution of the script to this 22 / 9 ratio and makes the orthographic size of the camera bigger so everybody sees the same in width. The height varies though. Is that the only way or are there other and better ways out there to solve the problem?
float cameraratio = 22 / 9;
float screenwidth = Screen.width;
float screenheight = Screen.height;
float screenratio = screenwidth / screenheight;
float multiplier = cameraratio / screenratio;
camera.orthographicSize = camera.orthographicSize * multiplier;