반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/06   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

Acoustic Cloud

유니티 PC 해상도 제작 본문

Dev/Unity

유니티 PC 해상도 제작

어클 2021. 7. 13. 13:40
반응형

유니티로 PC 플랫폼에서 해상도 옵션창을 만들어 보았다. 

 

대략 만들어진 UI모습

            
        // 선언 
        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];
        }

 

 

반응형