์ถœ์ฒ˜ 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 ์ ์šฉ

ย  ย  ย  ย  }

ย  ย  }