먼저 접근한 방식은, 원하는 해상도를 일일히 하나하나 버튼에 넣는것이었다.
하지만 인터넷 서핑도중 더 좋은 방법을 찾아내어 사용함.
// .....
[SerializeField] GameObject changeScreenImg;
[SerializeField] Toggle fullScreenToggle;
[SerializeField] TMP_Dropdown changeScreenDropdown; //tmp드롭다운 사용
FullScreenMode fullScreenMode;
private List<Resolution> resolutions = new List<Resolution>();
private int resolutionNum;
// ....
#region ChangeScreenOption
private void InitScreenResolution() // make Screen Resolutions and add it into Dropdown
{
resolutions.AddRange(Screen.resolutions);
changeScreenDropdown.options.Clear();
int screenOptionNum = 0;
foreach (Resolution item in resolutions)
{
TMP_Dropdown.OptionData option = new TMP_Dropdown.OptionData();
option.text = item.width + " x " + item.height + " " + item.refreshRateRatio + "hz";
changeScreenDropdown.options.Add(option);
if (item.width == Screen.width && item.height == Screen.height)
{
changeScreenDropdown.value = screenOptionNum;
}
screenOptionNum++;
}
changeScreenDropdown.RefreshShownValue();
fullScreenToggle.isOn = Screen.fullScreenMode.Equals(FullScreenMode.FullScreenWindow) ? true : false;
}
public void OnClickChangeScreenDropdown(int x) //get num of choosen Screen Resolution from Dropdown
{
resolutionNum = x;
}
public void OnClickFullScreenToggle(bool isFull) // check Screen is already fulled or not
{
fullScreenMode = isFull ? FullScreenMode.FullScreenWindow : FullScreenMode.Windowed;
}
public void OnClickAdmitScreenChangeBtn() // Click Admit Btn, set up Screen Resolution and Fulled Window
{
Screen.SetResolution(resolutions[resolutionNum].width, resolutions[resolutionNum].height, fullScreenMode);
changeScreenImg.SetActive(false);
menuCloseBtn.SetActive(true);
}
#endregion
뭔뜻인지 이해는 안가지만, 복사 붙혀넣기 하면 이해가 될것이다..
다만
드롭다운이나 토글에서 해당 함수를 OnClick()메서드에 넣어줄때,
Dynamic에서 넣어줘야한다!