Mobile Aspect Ratio - TeamCrazyPerformance/Game_study GitHub Wiki

์ค€๋น„

  • ๋นŒ๋“œ ์„ธํŒ…์„ ์•ˆ๋“œ๋กœ์ด๋“œ๋กœ ์„ค์ •
  • image
  • ๋ชจ๋ฐ”์ผ ํ•ด์ƒ๋„ ์กฐ์‚ฌ ๋ฐ ์„ ์ •(2160 * 1080 Landscape)
  • canvas ์„ค์ •
  • image
  • ProjectSetting์—์„œ ํ™”๋ฉด ํšŒ์ „ ์„ค์ •
  • image

CameraResolution

  • ๋ชจ๋“  ์”ฌ ์นด๋ฉ”๋ผ์— ์ ์šฉ

public class CameraResolution : MonoBehaviour
{
    void Awake()
    {
        Camera camera = GetComponent();
        Rect rect = camera.rect;
        float scaleheight = ((float)Screen.width / Screen.height) / ((float)16 / 9); // (์„ธ๋กœ / ๊ฐ€๋กœ)
        float scalewidth = 1f / scaleheight;
        if (scaleheight < 1)
        {
            rect.height = scaleheight;
            rect.y = (1f - scaleheight) / 2f;
        }
        else
        {
            rect.width = scalewidth;
            rect.x = (1f - scalewidth) / 2f;
        }
        camera.rect = rect;
    }

    void OnPreCull() => GL.Clear(true, true, Color.black);
}

์ฐธ๊ณ 

19์˜ค์„ฑํ˜

โš ๏ธ **GitHub.com Fallback** โš ๏ธ