TIL

23.10.25

llIlIIllII 2023. 10. 25. 21:14

Unity : 해상도 가져오기

유니티의 해상도를 가져오는 코드는 간단하다.

using UnityEngine;

public class ResolutionManager : MonoBehaviour
{
    void Start()
    {
        // 현재 화면 해상도를 가져오기
        int screenWidth = Screen.width;
        int screenHeight = Screen.height;

        // 결과 출력
        Debug.Log("화면 해상도: " + screenWidth + "x" + screenHeight);
    }
}

 

이 외에도 현재 사용하고 있는 모니터의 해상도를 가져오는 코드는 아래와 같다.

using UnityEngine;

public class ResolutionManager : MonoBehaviour
{
    void Start()
    {
        // 현재 모니터 해상도 얻기
        Resolution currentResolution = Screen.currentResolution;

        // 결과 출력
        Debug.Log("현재 모니터 해상도: " + currentResolution.width + "x" + currentResolution.height);
    }
}