Version: Unity 6.3 Beta (6000.3)
LanguageEnglish
  • C#

GameWindow.SetResolution

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public AsyncOperation SetResolution(int width, int height);

Parameters

Parameter Description
width The new width of the window in pixels.
height The new height of the window in pixels.

Returns

AsyncOperation An AsyncOperation that represents the operation.

Description

Sets the resolution of the window.

If the window's FullScreenMode is Windowed, the window is resized to match the specified resolution, and the rendering resolution is set accordingly. If the FullScreenMode is maximized or fullscreen, the window occupies the entire screen and the rendering resolution is set to the specified values, which may cause the image to be upscaled or downscaled if the resolution does not match the screen size.

using UnityEngine;
using UnityEngine.Windowing;

public class SetResolutionExample : MonoBehaviour { AsyncOperation asyncOperation = null;

void Start() { var window = GameWindow.Main; asyncOperation = window.SetResolution(1280, 720); }

void Update() { if (asyncOperation != null && asyncOperation.IsDone) { Debug.Log("Window resolution set successfully."); asyncOperation = null; } } }

Declaration

public AsyncOperation SetResolution(int width, int height, FullScreenMode fullScreenMode);

Parameters

Parameter Description
width The new width of the window in pixels.
height The new height of the window in pixels.
fullScreenMode The new FullScreenMode for the window.

Returns

AsyncOperation An AsyncOperation that represents the operation.

Description

Sets the resolution and full-screen mode of the window.

using UnityEngine;
using UnityEngine.Windowing;

public class SetResolutionFullScreenExample : MonoBehaviour { AsyncOperation asyncOperation = null;

void Start() { var window = GameWindow.Main; asyncOperation = window.SetResolution(1920, 1080, FullScreenMode.FullScreenWindow); }

void Update() { if (asyncOperation != null && asyncOperation.IsDone) { Debug.Log("Window resolution and full-screen mode set successfully."); asyncOperation = null; } } }

Declaration

public AsyncOperation SetResolution(int width, int height, FullScreenMode fullScreenMode, RefreshRate preferredRefreshRate);

Parameters

Parameter Description
width The new width of the window in pixels.
height The new height of the window in pixels.
fullScreenMode The new for the window.
preferredRefreshRate The preferred refresh rate for the window.

Returns

AsyncOperation An AsyncOperation that represents the operation.

Description

Sets the resolution, full-screen mode, and preferred refresh rate of the window.

using UnityEngine;
using UnityEngine.Windowing;

public class SetResolutionRefreshRateExample : MonoBehaviour { AsyncOperation asyncOperation = null;

void Start() { var window = GameWindow.Main; asyncOperation = window.SetResolution(1920, 1080, FullScreenMode.ExclusiveFullScreen, new RefreshRate{ numerator = 60, denominator = 1 }); }

void Update() { if (asyncOperation != null && asyncOperation.IsDone) { Debug.Log("Window resolution, full-screen mode, and refresh rate set successfully."); asyncOperation = null; } } }