GetResolution()
Gets the resolution of the window.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Windowing
- Assembly: UnityEngine.WindowingModule
public Resolution GetResolution()
Returns
Type | Description |
|---|---|
| Resolution | A 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"); }}