본문 바로가기

TIL

23.10.25

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);
    }
}

'TIL' 카테고리의 다른 글

23.10.27  (0) 2023.10.30
23.10.26  (0) 2023.10.26
23.10.24  (0) 2023.10.24
23.10.23  (0) 2023.10.23
23.10.20  (0) 2023.10.23