Acoustic Cloud
유니티 PC 해상도 제작 본문
반응형
유니티로 PC 플랫폼에서 해상도 옵션창을 만들어 보았다.
// 선언
int currentResIndex = 0;
List<string> lstResolutions = new List<string>(); // 전체 해상도
List<Resolution> lstFullHDRes = new List<Resolution>(); // 1.777 비율의 해상도
bool bFullScreen = false; // 풀스크린 여부
private void Awake()
{
// 해상도 초기화
Resolution[] resolutions = Screen.resolutions;
foreach (Resolution res in resolutions)
{
string str = res.width + "x" + res.height;
//print(res.width + "x" + res.height);
float ratio = (float)res.width / (float)res.height;
if (ratio > 1.7f && ratio < 1.8f)
{
lstResolutions.Add(str);
lstFullHDRes.Add(res);
}
}
}
// 적용버튼클릭
public void OnClick_Apply()
{
Screen.SetResolution(lstFullHDRes[currentResIndex].width, lstFullHDRes[currentResIndex].height, bFullScreen);
}
// 풀스크린 버튼 클릭
public void OnClick_Fullscreen()
{
bFullScreen = true;
}
// 윈도우 모드 버튼 클릭
public void OnClick_Windowed()
{
bFullScreen = false;
}
// 해상도 왼쪽 버튼
public void OnClick_Left()
{
currentResIndex--;
if (currentResIndex < 0)
{
currentResIndex = 0;
}
resolution.text = lstResolutions[currentResIndex];
}
// 해상도 오른쪽 버튼
public void OnClick_Right()
{
currentResIndex++;
if (currentResIndex >= lstResolutions.Count)
{
currentResIndex = lstResolutions.Count - 1;
}
resolution.text = lstResolutions[currentResIndex];
}
반응형
'Dev > Unity' 카테고리의 다른 글
유니티 iOS 로그인 + Firebase 인증 (2) | 2024.07.20 |
---|---|
Unity Firebase 구글 로그인 인증 - iOS편 (0) | 2024.07.20 |
유니티(Android) 익스포트시 Firebase 설정 (0) | 2023.02.11 |
PS4 controller map for Unity (0) | 2020.12.28 |