ย ย 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); // SetResolution ํ•จ์ˆ˜ ์ œ๋Œ€๋กœ ์‚ฌ์šฉํ•˜๊ธฐ


ย  ย  ย  ย  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 ์ ์šฉ

ย  ย  ย  ย  }

ย  ย  }




====


์ด๋ ‡๊ฒŒ ํ–ˆ๋Š”๋ฐ ๋ชจ๋ฐ”์ผ๋กœ ๋นŒ๋“œํ•˜๋ฉด ์™œ ์œ„์•„๋ž˜๊ฐ€ ์งค๋ฆด๊นŒ...