- Home /
Question by
Snare_X · Jul 08, 2020 at 08:44 AM ·
2d2d game2d sprites2d camera
Changing the orthographicSize of the camera to make sure play field fits
I've been trying to find a way to future proof my game to handle different resolutions. My problem is some aspect ratios are zooming in too far or too far out and cutting sprites off. (UI is perfectly fine) I know there's a better solution than my crude method I'm using at the moment.
Here's what I just whiped up to make this work for the time being.
Thanks in advance
private Camera MC;
private float rat;
private void Start()
{
MC = GetComponent<Camera>();
rat = (MC.scaledPixelHeight / MC.scaledPixelWidth);
if (rat == 2)
{
MC.orthographicSize = 68;
} else
{
MC.orthographicSize = 60;
}
}
Comment