Unity3D改变屏幕分辨率

using UnityEngine;

public class FullScreen : MonoBehaviour
{
    
    
    void Update()
    {
    
    
        //  按ESC退出全屏
        if (Input.GetKey(KeyCode.Escape))
        {
    
    
            Screen.fullScreen = false; //退出全屏         
        }

        //设置为1080*720不全屏
        if (Input.GetKey(KeyCode.F1))
        {
    
    
            Screen.SetResolution(1080, 720, false);
        }

        //设置1080*720的全屏
        if (Input.GetKey(KeyCode.F2))
        {
    
    
            Screen.SetResolution(1080, 720, true);
        }

        if (Input.GetKey(KeyCode.F3))
        {
    
    
            Resolution[] resolutions = Screen.resolutions; //获取设置当前屏幕分辩率
            Screen.SetResolution(resolutions[resolutions.Length - 1].width, resolutions[resolutions.Length - 1].height,
                true); //设置当前分辨率
            Screen.fullScreen = true; //设置成全屏,
        }
    }
}

猜你喜欢

转载自blog.csdn.net/qq_36382679/article/details/114279132