文档

Unity Engine

Unity Engine

GetResolution()

Gets the resolution of the window.
阅读时间1 分钟最后更新于 1 个月前

Definition

public Resolution GetResolution()

Returns

Type

Description

ResolutionA Resolution object that represents the current resolution of the window.

Remarks

If the window is running in windowed mode, this function retrieves the window’s resolution, in contrast to Screen.currentResolution, which returns the resolution of the display. Note that the fetched resolution refresh rate defaults to 0 if retrieving the window's refresh rate isn't supported on the current platform.

Examples

using UnityEngine;using UnityEngine.Windowing;public class WindowResolutionExample : MonoBehaviour{ void Start() { var window = GameWindow.Main; Resolution res = window.GetResolution(); Debug.Log($"Resolution: {res.width}x{res.height} @ {res.refreshRate}Hz"); }}