Screen.resolutions 分辨率列表(安卓平台试了不能用此方法,最好用宏定义判断一下平台)

C# => public static [] resolutions;

Description 描述

All fullscreen resolutions supported by the monitor (Read Only).

显示器支持的所有全屏分辨率。(只读)

The returned resolutions are sorted by width, lower resolutions come first. Note that the array will always be empty on Android devices since the resolution is variable (within reason) and so there is no restricted set of resolutions to choose from.

返回分辨率的列表,安装宽带排序,较低的分辨率排在前面。注意,在Android设备该列表总是为空,因为该分辨率是变化的,所以选择没有限制的分辨率。

C#:

using UnityEngine;

using System.Collections;

public class ExampleClass : MonoBehaviour {

    void Start() {

        Resolution[] resolutions = Screen.resolutions;

        foreach (Resolution res in resolutions) {

            print(res.width + "x" + res.height);

        }

        Screen.SetResolution(resolutions[].width, resolutions[].height, true);

    }

}

设置全屏:

Screen.SetResolution(Screen.width, Screen.height, true);//true全屏,false不是全屏

05-19 13:29