Version: 1.10
LanguageEnglish
  • C#

GameWindow

class in UnityEngine.Windowing

/

Implemented in:UnityEngine.CoreModule

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

Description

Represents a native OS window managed by Unity's windowing system. This API is currently available only in EmbeddedLinux and QNX platforms.

The GameWindow class provides APIs to query and control window properties such as title, size, position, display, and fullscreen mode. It also supports asynchronous operations for moving, resizing, and destroying windows.

Static Properties

MainGets the main window of the application.

Public Methods

DisposeAsyncAsynchronously disposes of the window and releases its resources.Use this method to dispose of a secondary window when you no longer need it. You cannot dispose of the main window. To close the main window, use Application.Quit instead. The DisposeAsync method clears all registered position and resolution change callbacks before it disposes of the window. After disposal, this GameWindow instance is no longer valid and you must not use it. The following code example demonstrates how to use this method to dispose of a secondary window.
GetDisplayInfoGets the display information of the display that holds the window.
GetFullScreenModeGets the full-screen mode of the window.
GetHashCodeReturns the hash code for this window.
GetHeightGets the height of the window.
GetLogicalDpiGets the logical DPI of the window.Note that the logical DPI defaults to 0 if it's not supported by the platform.
GetPositionGets the position of the window relative to the top-left corner of the screen.
GetResolutionGets the resolution of the window.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.
GetTitleGets the title of the window.
GetWidthGets the width of the window.
IsMainReturns true if this window is the main application window.
IsValidReturns true if this window is valid and not destroyed.
MoveToMoves the window to a new position on its current display asynchronously.
PositionChangedThisFrameChecks if the window's position changed during the current frame.Use this in MonoBehaviour.Update, MonoBehaviour.FixedUpdate, or MonoBehaviour.LateUpdate to check if the window's position changed during the current frame.
RegisterPositionChangedCallbackRegisters a callback that is invoked when the window's position changes.
RegisterResolutionChangedCallbackRegisters a callback that is invoked when the window's resolution changes.
ResolutionChangedThisFrameChecks if the window's resolution changed during the current frame.Use this in MonoBehaviour.Update, MonoBehaviour.FixedUpdate, or MonoBehaviour.LateUpdate to check if the window's resolution changed during the current frame.
SetResolutionSets the resolution of the window.
SetTitleSets the title of the window.
UnregisterPositionChangedCallbackUnregisters a callback so it is no longer invoked when the window's position changes.
UnregisterResolutionChangedCallbackUnregisters a callback so it is no longer invoked when the window's resolution changes.