์ถ์ฒ https://giseung.tistory.com/19
public void SetResolution()
ย ย {
ย ย ย ย int setWidth = 1920; // ์ฌ์ฉ์ ์ค์ ๋๋น
ย ย ย ย int setHeight = 1080; // ์ฌ์ฉ์ ์ค์ ๋์ด
ย ย ย ย int deviceWidth = Screen.width;ย
ย ย ย ย int deviceHeight = Screen.height;ย
ย ย ย ย Screen.SetResolution(setWidth, (int)(((float)deviceHeight / deviceWidth) * setWidth), true);ย
ย ย ย ย if ((float)setWidth / setHeight < (float)deviceWidth / deviceHeight) // ๊ธฐ๊ธฐ์ ํด์๋ ๋น๊ฐ ๋ ํฐ ๊ฒฝ์ฐ
ย ย ย ย {
ย ย ย ย ย ย float newWidth = ((float)setWidth / setHeight) / ((float)deviceWidth / deviceHeight); // ์๋ก์ด ๋๋น
ย ย ย ย ย ย Camera.main.rect = new Rect((1f - newWidth) / 2f, 0f, newWidth, 1f); // ์๋ก์ด Rect ์ ์ฉ
ย ย ย ย }
ย ย ย ย else // ๊ฒ์์ ํด์๋ ๋น๊ฐ ๋ ํฐ ๊ฒฝ์ฐ
ย ย ย ย {
ย ย ย ย ย ย float newHeight = ((float)deviceWidth / deviceHeight) / ((float)setWidth / setHeight); // ์๋ก์ด ๋์ด
ย ย ย ย ย ย Camera.main.rect = new Rect(0f, (1f - newHeight) / 2f, 1f, newHeight); // ์๋ก์ด Rect ์ ์ฉ
ย ย ย ย }
ย ย }
๊ฐ์ฌํฉ๋๋ค ํด๋ณผ๊ฒ์