Operating System functions. OS wraps the most common functionality to communicate with the host operating system, such as the clipboard, video driver, date and time, timers, environment variables, execution of binaries, command line, etc.

Static variables

@:native("Clipboard")staticCLIPBOARD:String

The clipboard from the host OS. Might be unavailable on some platforms.

@:native("CurrentScreen")staticCURRENT_SCREEN:Int

The current screen index (starting from 0).

@:native("DeltaSmoothing")staticDELTA_SMOOTHING:Bool

If true, the engine filters the time delta measured between each frame, and attempts to compensate for random variation. This will only operate on systems where V-Sync is active.

@:native("ExitCode")staticEXIT_CODE:Int

The exit code passed to the OS when the main loop exits. By convention, an exit code of 0 indicates success whereas a non-zero exit code indicates an error. For portability reasons, the exit code should be set between 0 and 125 (inclusive).

Note: This value will be ignored if using godot.SceneTree.quit with an exit_code argument passed.

@:native("KeepScreenOn")staticKEEP_SCREEN_ON:Bool

If true, the engine tries to keep the screen on while the game is running. Useful on mobile.

@:native("LowProcessorUsageMode")staticLOW_PROCESSOR_USAGE_MODE:Bool

If true, the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile.

@:native("LowProcessorUsageModeSleepUsec")staticLOW_PROCESSOR_USAGE_MODE_SLEEP_USEC:Int

The amount of sleeping between frames when the low-processor usage mode is enabled (in microseconds). Higher values will result in lower CPU usage.

@:native("MaxWindowSize")staticMAX_WINDOW_SIZE:Vector2

The maximum size of the window (without counting window manager decorations). Does not affect fullscreen mode. Set to (0, 0) to reset to the system default value.

@:native("MinWindowSize")staticMIN_WINDOW_SIZE:Vector2

The minimum size of the window in pixels (without counting window manager decorations). Does not affect fullscreen mode. Set to (0, 0) to reset to the system's default value.

Note: By default, the project window has a minimum size of Vector2(64, 64). This prevents issues that can arise when the window is resized to a near-zero size.

@:native("ScreenOrientation")staticSCREEN_ORIENTATION:OS_ScreenOrientationEnum

The current screen orientation.

@:native("Singleton")staticread onlySINGLETON:Object

@:native("TabletDriver")staticTABLET_DRIVER:String

The current tablet driver in use.

@:native("VsyncEnabled")staticVSYNC_ENABLED:Bool

If true, vertical synchronization (Vsync) is enabled.

@:native("VsyncViaCompositor")staticVSYNC_VIA_COMPOSITOR:Bool

If true and vsync_enabled is true, the operating system's window compositor will be used for vsync when the compositor is enabled and the game is in windowed mode.

Note: This option is experimental and meant to alleviate stutter experienced by some users. However, some users have experienced a Vsync framerate halving (e.g. from 60 FPS to 30 FPS) when using it.

Note: This property is only implemented on Windows.

@:native("WindowBorderless")staticWINDOW_BORDERLESS:Bool

If true, removes the window frame.

Note: Setting window_borderless to false disables per-pixel transparency.

@:native("WindowFullscreen")staticWINDOW_FULLSCREEN:Bool

If true, the window is fullscreen.

@:native("WindowMaximized")staticWINDOW_MAXIMIZED:Bool

If true, the window is maximized.

@:native("WindowMinimized")staticWINDOW_MINIMIZED:Bool

If true, the window is minimized.

@:native("WindowPerPixelTransparencyEnabled")staticWINDOW_PER_PIXEL_TRANSPARENCY_ENABLED:Bool

If true, the window background is transparent and the window frame is removed.

Use get_tree().get_root().set_transparent_background(true) to disable main viewport background rendering.

Note: This property has no effect if setting is disabled.

Note: This property is implemented on HTML5, Linux, macOS, Windows, and Android. It can't be changed at runtime for Android. Use to set it at startup instead.

@:native("WindowPosition")staticWINDOW_POSITION:Vector2

The window position relative to the screen, the origin is the top left corner, +Y axis goes to the bottom and +X axis goes to the right.

@:native("WindowResizable")staticWINDOW_RESIZABLE:Bool

If true, the window is resizable by the user.

@:native("WindowSize")staticWINDOW_SIZE:Vector2

The size of the window (without counting window manager decorations).

Static methods

@:native("Alert")staticalert(text:String, ?title:String):Void

Displays a modal dialog box using the host OS' facilities. Execution is blocked until the dialog is closed.

@:native("CanDraw")staticcanDraw():Bool

Returns true if the host OS allows drawing.

@:native("CanUseThreads")staticcanUseThreads():Bool

Returns true if the current host platform is using multiple threads.

@:native("CenterWindow")staticcenterWindow():Void

Centers the window on the screen if in windowed mode.

@:native("CloseMidiInputs")staticcloseMidiInputs():Void

Shuts down system MIDI driver.

Note: This method is implemented on Linux, macOS and Windows.

@:native("DelayMsec")staticdelayMsec(msec:Int):Void

Delays execution of the current thread by msec milliseconds. msec must be greater than or equal to 0. Otherwise, godot.OS.delayMsec will do nothing and will print an error message.

Note: godot.OS.delayMsec is a blocking way to delay code execution. To delay code execution in a non-blocking way, see godot.SceneTree.createTimer. Yielding with godot.SceneTree.createTimer will delay the execution of code placed below the yield without affecting the rest of the project (or editor, for Godot.EditorPlugins and Godot.EditorScripts).

Note: When godot.OS.delayMsec is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using godot.OS.delayMsec as part of an Godot.EditorPlugin or Godot.EditorScript, it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).

@:native("DelayUsec")staticdelayUsec(usec:Int):Void

Delays execution of the current thread by usec microseconds. usec must be greater than or equal to 0. Otherwise, godot.OS.delayUsec will do nothing and will print an error message.

Note: godot.OS.delayUsec is a blocking way to delay code execution. To delay code execution in a non-blocking way, see godot.SceneTree.createTimer. Yielding with godot.SceneTree.createTimer will delay the execution of code placed below the yield without affecting the rest of the project (or editor, for Godot.EditorPlugins and Godot.EditorScripts).

Note: When godot.OS.delayUsec is called on the main thread, it will freeze the project and will prevent it from redrawing and registering input until the delay has passed. When using godot.OS.delayUsec as part of an Godot.EditorPlugin or Godot.EditorScript, it will freeze the editor but won't freeze the project if it is currently running (since the project is an independent child process).

@:native("DumpMemoryToFile")staticdumpMemoryToFile(file:String):Void

Dumps the memory allocation ringlist to a file (only works in debug).

Entry format per line: "Address - Size - Description".

@:native("DumpResourcesToFile")staticdumpResourcesToFile(file:String):Void

Dumps all used resources to file (only works in debug).

Entry format per line: "Resource Type : Resource Location".

At the end of the file is a statistic of all used Resource Types.

@:native("Execute")staticexecute(path:String, arguments:Array<String>, ?blocking:Bool, ?output:Array, ?readStderr:Bool):Int

Execute the file at the given path with the arguments passed as an array of strings. Platform path resolution will take place. The resolved file must exist and be executable.

The arguments are used in the given order and separated by a space, so OS.execute("ping", ["-w", "3", "godotengine.org"], false) will resolve to ping -w 3 godotengine.org in the system's shell.

This method has slightly different behavior based on whether the blocking mode is enabled.

If blocking is true, the Godot thread will pause its execution while waiting for the process to terminate. The shell output of the process will be written to the output array as a single string. When the process terminates, the Godot thread will resume execution.

If blocking is false, the Godot thread will continue while the new process runs. It is not possible to retrieve the shell output in non-blocking mode, so output will be empty.

The return value also depends on the blocking mode. When blocking, the method will return an exit code of the process. When non-blocking, the method returns a process ID, which you can use to monitor the process (and potentially terminate it with godot.OS.kill). If the process forking (non-blocking) or opening (blocking) fails, the method will return -1 or another exit code.

Example of blocking mode and retrieving the shell output:


var output = []
var exit_code = OS.execute("ls", ["-l", "/tmp"], true, output)

Example of non-blocking mode, running another instance of the project and storing its process ID:


var pid = OS.execute(OS.get_executable_path(), [], false)

If you wish to access a shell built-in or perform a composite command, a platform-specific shell can be invoked. For example:


OS.execute("CMD.exe", ["/C", "cd %TEMP% &amp;&amp; dir"], true, output)

Note: This method is implemented on Android, iOS, Linux, macOS and Windows.

Note: To execute a Windows command interpreter built-in command, specify cmd.exe in path, /c as the first argument, and the desired command as the second argument.

Note: To execute a PowerShell built-in command, specify powershell.exe in path, -Command as the first argument, and the desired command as the second argument.

Note: To execute a Unix shell built-in command, specify shell executable name in path, -c as the first argument, and the desired command as the second argument.

Parameters:

output

If the parameter is null, then the default value is new Godot.Collections.Array { }

@:native("FindScancodeFromString")staticfindScancodeFromString(string:String):Int

Returns the scancode of the given string (e.g. "Escape").

@:native("GetAudioDriverCount")staticgetAudioDriverCount():Int

Returns the total number of available audio drivers.

@:native("GetAudioDriverName")staticgetAudioDriverName(driver:Int):String

Returns the audio driver name for the given index.

@:native("GetBorderlessWindow")staticgetBorderlessWindow():Bool

@:native("GetCacheDir")staticgetCacheDir():String

Returns the global cache data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the XDG_CACHE_HOME environment variable before starting the project. See [https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html](File paths in Godot projects) in the documentation for more information. See also godot.OS.getConfigDir and godot.OS.getDataDir.

Not to be confused with godot.OS.getUserDataDir, which returns the project-specific user data path.

@:native("GetClipboard")staticgetClipboard():String

staticinlinegetCmdlineArgs():Array<String>

Returns the command-line arguments passed to the engine.

Command-line arguments can be written in any form, including both --key value and --key=value forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.

You can also incorporate environment variables using the godot.OS.getEnvironment method.

You can set to define command-line arguments to be passed by the editor when running the project.

Here's a minimal example on how to parse command-line arguments into a dictionary using the --key=value form for arguments:


var arguments = {}
for argument in OS.get_cmdline_args():
if argument.find("=") &gt; -1:
var key_value = argument.split("=")
arguments[key_value[0].lstrip("--")] = key_value[1]
else:
# Options without an argument will be present in the dictionary,
# with the value set to an empty string.
arguments[argument.lstrip("--")] = ""

@:native("GetConfigDir")staticgetConfigDir():String

Returns the global user configuration directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the XDG_CONFIG_HOME environment variable before starting the project. See [https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html](File paths in Godot projects) in the documentation for more information. See also godot.OS.getCacheDir and godot.OS.getDataDir.

Not to be confused with godot.OS.getUserDataDir, which returns the project-specific user data path.

staticinlinegetConnectedMidiInputs():Array<String>

Returns an array of MIDI device names.

The returned array will be empty if the system MIDI driver has not previously been initialised with godot.OS.openMidiInputs.

Note: This method is implemented on Linux, macOS and Windows.

@:native("GetCurrentScreen")staticgetCurrentScreen():Int

@:native("GetCurrentTabletDriver")staticgetCurrentTabletDriver():String

@:native("GetCurrentVideoDriver")staticgetCurrentVideoDriver():OS_VideoDriver

Returns the currently used video driver, using one of the values from godot.OS_VideoDriver.

@:native("GetDataDir")staticgetDataDir():String

Returns the global user data directory according to the operating system's standards. On desktop platforms, this path can be overridden by setting the XDG_DATA_HOME environment variable before starting the project. See [https://docs.godotengine.org/en/latest/tutorials/io/data_paths.html](File paths in Godot projects) in the documentation for more information. See also godot.OS.getCacheDir and godot.OS.getConfigDir.

Not to be confused with godot.OS.getUserDataDir, which returns the project-specific user data path.

@:native("GetDate")staticgetDate(?utc:Bool):Dictionary

Returns current date as a dictionary of keys: year, month, day, weekday, dst (Daylight Savings Time).

@:native("GetDatetime")staticgetDatetime(?utc:Bool):Dictionary

Returns current datetime as a dictionary of keys: year, month, day, weekday, dst (Daylight Savings Time), hour, minute, second.

@:native("GetDatetimeFromUnixTime")staticgetDatetimeFromUnixTime(unixTimeVal:Int64):Dictionary

Gets a dictionary of time values corresponding to the given UNIX epoch time (in seconds).

The returned Dictionary's values will be the same as godot.OS.getDatetime, with the exception of Daylight Savings Time as it cannot be determined from the epoch.

@:native("GetDynamicMemoryUsage")staticgetDynamicMemoryUsage():UInt64

Returns the total amount of dynamic memory used (only works in debug).

@:native("GetEnvironment")staticgetEnvironment(variable:String):String

Returns the value of an environment variable. Returns an empty string if the environment variable doesn't exist.

Note: Double-check the casing of variable. Environment variable names are case-sensitive on all platforms except Windows.

@:native("GetExecutablePath")staticgetExecutablePath():String

Returns the path to the current engine executable.

@:native("GetExitCode")staticgetExitCode():Int

staticinlinegetGrantedPermissions():Array<String>

With this function, you can get the list of dangerous permissions that have been granted to the Android application.

Note: This method is implemented on Android.

@:native("GetImeSelection")staticgetImeSelection():Vector2

Returns the IME cursor position (the currently-edited portion of the string) relative to the characters in the composition string.

godot.MainLoop.notificationOsImeUpdate is sent to the application to notify it of changes to the IME cursor position.

Note: This method is implemented on macOS.

@:native("GetImeText")staticgetImeText():String

Returns the IME intermediate composition string.

godot.MainLoop.notificationOsImeUpdate is sent to the application to notify it of changes to the IME composition string.

Note: This method is implemented on macOS.

@:native("GetLatinKeyboardVariant")staticgetLatinKeyboardVariant():String

Returns the current latin keyboard variant as a String.

Possible return values are: "QWERTY", "AZERTY", "QZERTY", "DVORAK", "NEO", "COLEMAK" or "ERROR".

Note: This method is implemented on Linux, macOS and Windows. Returns "QWERTY" on unsupported platforms.

@:native("GetLocale")staticgetLocale():String

Returns the host OS locale as a string of the form language_Script_COUNTRY_VARIANT@extra. If you want only the language code and not the fully specified locale from the OS, you can use godot.OS.getLocaleLanguage.

language - 2 or 3-letter [https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes](language code), in lower case.

Script - optional, 4-letter [https://en.wikipedia.org/wiki/ISO_15924](script code), in title case.

COUNTRY - optional, 2 or 3-letter [https://en.wikipedia.org/wiki/ISO_3166-1](country code), in upper case.

VARIANT - optional, language variant, region and sort order. Variant can have any number of underscored keywords.

extra - optional, semicolon separated list of additional key words. Currency, calendar, sort order and numbering system information.

@:native("GetLocaleLanguage")staticgetLocaleLanguage():String

Returns the host OS locale's 2 or 3-letter [https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes](language code) as a string which should be consistent on all platforms. This is equivalent to extracting the language part of the godot.OS.getLocale string.

This can be used to narrow down fully specified locale strings to only the "common" language code, when you don't need the additional information about country code or variants. For example, for a French Canadian user with fr_CA locale, this would return fr.

@:native("GetLowProcessorUsageModeSleepUsec")staticgetLowProcessorUsageModeSleepUsec():Int

@:native("GetMaxWindowSize")staticgetMaxWindowSize():Vector2

@:native("GetMinWindowSize")staticgetMinWindowSize():Vector2

@:native("GetModelName")staticgetModelName():String

Returns the model name of the current device.

Note: This method is implemented on Android and iOS. Returns "GenericDevice" on unsupported platforms.

@:native("GetName")staticgetName():String

Returns the name of the host OS. Possible values are: "Android", "iOS", "HTML5", "OSX", "Server", "Windows", "UWP", "X11".

@:native("GetNativeHandle")staticgetNativeHandle(handleType:OS_HandleType):Int64

Returns internal structure pointers for use in GDNative plugins.

Note: This method is implemented on Linux and Windows (other OSs will soon be supported).

@:native("GetPowerPercentLeft")staticgetPowerPercentLeft():Int

Returns the amount of battery left in the device as a percentage. Returns -1 if power state is unknown.

Note: This method is implemented on Linux, macOS and Windows.

@:native("GetPowerSecondsLeft")staticgetPowerSecondsLeft():Int

Returns an estimate of the time left in seconds before the device runs out of battery. Returns -1 if power state is unknown.

Note: This method is implemented on Linux, macOS and Windows.

@:native("GetPowerState")staticgetPowerState():OS_PowerState

Returns the current state of the device regarding battery and power. See godot.OS_PowerState constants.

Note: This method is implemented on Linux, macOS and Windows.

@:native("GetProcessId")staticgetProcessId():Int

Returns the project's process ID.

Note: This method is implemented on Android, iOS, Linux, macOS and Windows.

@:native("GetProcessorCount")staticgetProcessorCount():Int

Returns the number of threads available on the host machine.

@:native("GetRealWindowSize")staticgetRealWindowSize():Vector2

Returns the window size including decorations like window borders.

@:native("GetScancodeString")staticgetScancodeString(code:UInt):String

Returns the given scancode as a string (e.g. Return values: "Escape", "Shift+Escape").

See also godot.InputEventKey.scancode and godot.InputEventKey.getScancodeWithModifiers.

@:native("GetScreenCount")staticgetScreenCount():Int

Returns the number of displays attached to the host machine.

@:native("GetScreenDpi")staticgetScreenDpi(?screen:Int):Int

Returns the dots per inch density of the specified screen. If screen is -1 (the default value), the current screen will be used.

Note: On macOS, returned value is inaccurate if fractional display scaling mode is used.

Note: On Android devices, the actual screen densities are grouped into six generalized densities:


ldpi - 120 dpi
mdpi - 160 dpi
hdpi - 240 dpi
xhdpi - 320 dpi
xxhdpi - 480 dpi
xxxhdpi - 640 dpi

Note: This method is implemented on Android, Linux, macOS and Windows. Returns 72 on unsupported platforms.

@:native("GetScreenMaxScale")staticgetScreenMaxScale():Single

Return the greatest scale factor of all screens.

Note: On macOS returned value is 2.0 if there is at least one hiDPI (Retina) screen in the system, and 1.0 in all other cases.

Note: This method is implemented on macOS.

@:native("GetScreenOrientation")staticgetScreenOrientation():OS_ScreenOrientationEnum

@:native("GetScreenPosition")staticgetScreenPosition(?screen:Int):Vector2

Returns the position of the specified screen by index. If screen is -1 (the default value), the current screen will be used.

@:native("GetScreenScale")staticgetScreenScale(?screen:Int):Single

Return the scale factor of the specified screen by index. If screen is -1 (the default value), the current screen will be used.

Note: On macOS returned value is 2.0 for hiDPI (Retina) screen, and 1.0 for all other cases.

Note: This method is implemented on macOS.

@:native("GetScreenSize")staticgetScreenSize(?screen:Int):Vector2

Returns the dimensions in pixels of the specified screen. If screen is -1 (the default value), the current screen will be used.

@:native("GetSplashTickMsec")staticgetSplashTickMsec():UInt

Returns the amount of time in milliseconds it took for the boot logo to appear.

@:native("GetStaticMemoryPeakUsage")staticgetStaticMemoryPeakUsage():UInt64

Returns the maximum amount of static memory used (only works in debug).

@:native("GetStaticMemoryUsage")staticgetStaticMemoryUsage():UInt64

Returns the amount of static memory being used by the program in bytes (only works in debug).

@:native("GetSystemDir")staticgetSystemDir(dir:OS_SystemDir, ?sharedStorage:Bool):String

Returns the actual path to commonly used folders across different platforms. Available locations are specified in godot.OS_SystemDir.

Note: This method is implemented on Android, Linux, macOS and Windows.

Note: Shared storage is implemented on Android and allows to differentiate between app specific and shared directories. Shared directories have additional restrictions on Android.

@:native("GetSystemTimeMsecs")staticgetSystemTimeMsecs():UInt64

Returns the epoch time of the operating system in milliseconds.

@:native("GetSystemTimeSecs")staticgetSystemTimeSecs():UInt64

Returns the epoch time of the operating system in seconds.

@:native("GetTabletDriverCount")staticgetTabletDriverCount():Int

Returns the total number of available tablet drivers.

Note: This method is implemented on Windows.

@:native("GetTabletDriverName")staticgetTabletDriverName(idx:Int):String

Returns the tablet driver name for the given index.

Note: This method is implemented on Windows.

@:native("GetThreadCallerId")staticgetThreadCallerId():UInt64

Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications.

Note: Thread IDs are not deterministic and may be reused across application restarts.

@:native("GetTicksMsec")staticgetTicksMsec():UInt64

Returns the amount of time passed in milliseconds since the engine started.

@:native("GetTicksUsec")staticgetTicksUsec():UInt64

Returns the amount of time passed in microseconds since the engine started.

@:native("GetTime")staticgetTime(?utc:Bool):Dictionary

Returns current time as a dictionary of keys: hour, minute, second.

@:native("GetTimeZoneInfo")staticgetTimeZoneInfo():Dictionary

Returns the current time zone as a dictionary with the keys: bias and name.

@:native("GetUniqueId")staticgetUniqueId():String

Returns a string that is unique to the device.

Note: This string may change without notice if the user reinstalls/upgrades their operating system or changes their hardware. This means it should generally not be used to encrypt persistent data as the data saved before an unexpected ID change would become inaccessible. The returned string may also be falsified using external programs, so do not rely on the string returned by godot.OS.getUniqueId for security purposes.

Note: Returns an empty string on HTML5 and UWP, as this method isn't implemented on those platforms yet.

@:native("GetUnixTime")staticgetUnixTime():UInt64

Returns the current UNIX epoch timestamp in seconds.

Important: This is the system clock that the user can manually set. Never use this method for precise time calculation since its results are also subject to automatic adjustments by the operating system. Always use godot.OS.getTicksUsec or godot.OS.getTicksMsec for precise time calculation instead, since they are guaranteed to be monotonic (i.e. never decrease).

@:native("GetUnixTimeFromDatetime")staticgetUnixTimeFromDatetime(datetime:Dictionary):Int64

Gets an epoch time value from a dictionary of time values.

datetime must be populated with the following keys: year, month, day, hour, minute, second.

If the dictionary is empty 0 is returned. If some keys are omitted, they default to the equivalent values for the UNIX epoch timestamp 0 (1970-01-01 at 00:00:00 UTC).

You can pass the output from godot.OS.getDatetimeFromUnixTime directly into this function. Daylight Savings Time (dst), if present, is ignored.

@:native("GetUserDataDir")staticgetUserDataDir():String

Returns the absolute directory path where user data is written (user://).

On Linux, this is ~/.local/share/godot/app_userdata/[project_name], or ~/.local/share/[custom_name] if use_custom_user_dir is set.

On macOS, this is ~/Library/Application Support/Godot/app_userdata/[project_name], or ~/Library/Application Support/[custom_name] if use_custom_user_dir is set.

On Windows, this is %APPDATA%\Godot\app_userdata\[project_name], or %APPDATA%\[custom_name] if use_custom_user_dir is set. %APPDATA% expands to %USERPROFILE%\AppData\Roaming.

If the project name is empty, user:// falls back to res://.

Not to be confused with godot.OS.getDataDir, which returns the global (non-project-specific) user data directory.

@:native("GetVideoDriverCount")staticgetVideoDriverCount():Int

Returns the number of video drivers supported on the current platform.

@:native("GetVideoDriverName")staticgetVideoDriverName(driver:OS_VideoDriver):String

Returns the name of the video driver matching the given driver index. This index is a value from godot.OS_VideoDriver, and you can use godot.OS.getCurrentVideoDriver to get the current backend's index.

@:native("GetVirtualKeyboardHeight")staticgetVirtualKeyboardHeight():Int

Returns the on-screen keyboard's height in pixels. Returns 0 if there is no keyboard or if it is currently hidden.

@:native("GetWindowPerPixelTransparencyEnabled")staticgetWindowPerPixelTransparencyEnabled():Bool

@:native("GetWindowPosition")staticgetWindowPosition():Vector2

@:native("GetWindowSafeArea")staticgetWindowSafeArea():Rect2

Returns unobscured area of the window where interactive controls should be rendered.

@:native("GetWindowSize")staticgetWindowSize():Vector2

@:native("GlobalMenuAddItem")staticglobalMenuAddItem(menu:String, label:String, id:Dynamic, meta:Dynamic):Void

Add a new item with text "label" to global menu. Use "_dock" menu to add item to the macOS dock icon menu.

Note: This method is implemented on macOS.

@:native("GlobalMenuAddSeparator")staticglobalMenuAddSeparator(menu:String):Void

Add a separator between items. Separators also occupy an index.

Note: This method is implemented on macOS.

@:native("GlobalMenuClear")staticglobalMenuClear(menu:String):Void

Clear the global menu, in effect removing all items.

Note: This method is implemented on macOS.

@:native("GlobalMenuRemoveItem")staticglobalMenuRemoveItem(menu:String, idx:Int):Void

Removes the item at index "idx" from the global menu. Note that the indexes of items after the removed item are going to be shifted by one.

Note: This method is implemented on macOS.

@:native("HasEnvironment")statichasEnvironment(variable:String):Bool

Returns true if the environment variable with the name variable exists.

Note: Double-check the casing of variable. Environment variable names are case-sensitive on all platforms except Windows.

@:native("HasFeature")statichasFeature(tagName:String):Bool

Returns true if the feature for the given feature tag is supported in the currently running instance, depending on the platform, build etc. Can be used to check whether you're currently running a debug build, on a certain platform or arch, etc. Refer to the [https://docs.godotengine.org/en/3.4/tutorials/export/feature_tags.html](Feature Tags) documentation for more details.

Note: Tag names are case-sensitive.

@:native("HasTouchscreenUiHint")statichasTouchscreenUiHint():Bool

Returns true if the device has a touchscreen or emulates one.

@:native("HasVirtualKeyboard")statichasVirtualKeyboard():Bool

Returns true if the platform has a virtual keyboard, false otherwise.

@:native("HideVirtualKeyboard")statichideVirtualKeyboard():Void

Hides the virtual keyboard if it is shown, does nothing otherwise.

@:native("IsDebugBuild")staticisDebugBuild():Bool

Returns true if the Godot binary used to run the project is a debug export template, or when running in the editor.

Returns false if the Godot binary used to run the project is a release export template.

To check whether the Godot binary used to run the project is an export template (debug or release), use OS.has_feature("standalone") instead.

@:native("IsDeltaSmoothingEnabled")staticisDeltaSmoothingEnabled():Bool

@:native("IsInLowProcessorUsageMode")staticisInLowProcessorUsageMode():Bool

@:native("IsKeepScreenOn")staticisKeepScreenOn():Bool

@:native("IsOkLeftAndCancelRight")staticisOkLeftAndCancelRight():Bool

Returns true if the OK button should appear on the left and Cancel on the right.

@:native("IsScancodeUnicode")staticisScancodeUnicode(code:UInt):Bool

Returns true if the input scancode corresponds to a Unicode character.

@:native("IsStdoutVerbose")staticisStdoutVerbose():Bool

Returns true if the engine was executed with -v (verbose stdout).

@:native("IsUserfsPersistent")staticisUserfsPersistent():Bool

If true, the user:// file system is persistent, so that its state is the same after a player quits and starts the game again. Relevant to the HTML5 platform, where this persistence may be unavailable.

@:native("IsVsyncEnabled")staticisVsyncEnabled():Bool

@:native("IsVsyncViaCompositorEnabled")staticisVsyncViaCompositorEnabled():Bool

@:native("IsWindowAlwaysOnTop")staticisWindowAlwaysOnTop():Bool

Returns true if the window should always be on top of other windows.

@:native("IsWindowFocused")staticisWindowFocused():Bool

Returns true if the window is currently focused.

Note: Only implemented on desktop platforms. On other platforms, it will always return true.

@:native("IsWindowFullscreen")staticisWindowFullscreen():Bool

@:native("IsWindowMaximized")staticisWindowMaximized():Bool

@:native("IsWindowMinimized")staticisWindowMinimized():Bool

@:native("IsWindowResizable")staticisWindowResizable():Bool

@:native("KeyboardGetCurrentLayout")statickeyboardGetCurrentLayout():Int

Returns active keyboard layout index.

Note: This method is implemented on Linux, macOS and Windows.

@:native("KeyboardGetLayoutCount")statickeyboardGetLayoutCount():Int

Returns the number of keyboard layouts.

Note: This method is implemented on Linux, macOS and Windows.

@:native("KeyboardGetLayoutLanguage")statickeyboardGetLayoutLanguage(index:Int):String

Returns the ISO-639/BCP-47 language code of the keyboard layout at position index.

Note: This method is implemented on Linux, macOS and Windows.

@:native("KeyboardGetLayoutName")statickeyboardGetLayoutName(index:Int):String

Returns the localized name of the keyboard layout at position index.

Note: This method is implemented on Linux, macOS and Windows.

@:native("KeyboardSetCurrentLayout")statickeyboardSetCurrentLayout(index:Int):Void

Sets active keyboard layout.

Note: This method is implemented on Linux, macOS and Windows.

@:native("Kill")statickill(pid:Int):Error

Kill (terminate) the process identified by the given process ID (pid), e.g. the one returned by godot.OS.execute in non-blocking mode.

Note: This method can also be used to kill processes that were not spawned by the game.

Note: This method is implemented on Android, iOS, Linux, macOS and Windows.

@:native("MoveWindowToForeground")staticmoveWindowToForeground():Void

Moves the window to the front.

Note: This method is implemented on Linux, macOS and Windows.

@:native("NativeVideoIsPlaying")staticnativeVideoIsPlaying():Bool

Returns true if native video is playing.

Note: This method is only implemented on iOS.

@:native("NativeVideoPause")staticnativeVideoPause():Void

Pauses native video playback.

Note: This method is only implemented on iOS.

@:native("NativeVideoPlay")staticnativeVideoPlay(path:String, volume:Single, audioTrack:String, subtitleTrack:String):Error

Plays native video from the specified path, at the given volume and with audio and subtitle tracks.

Note: This method is only implemented on iOS.

@:native("NativeVideoStop")staticnativeVideoStop():Void

Stops native video playback.

Note: This method is implemented on iOS.

@:native("NativeVideoUnpause")staticnativeVideoUnpause():Void

Resumes native video playback.

Note: This method is implemented on iOS.

@:native("OpenMidiInputs")staticopenMidiInputs():Void

Initialises the singleton for the system MIDI driver.

Note: This method is implemented on Linux, macOS and Windows.

@:native("PrintAllResources")staticprintAllResources(?tofile:String):Void

Shows all resources in the game. Optionally, the list can be written to a file by specifying a file path in tofile.

@:native("PrintAllTexturesBySize")staticprintAllTexturesBySize():Void

Shows the list of loaded textures sorted by size in memory.

@:native("PrintResourcesByType")staticprintResourcesByType(types:HaxeArray<String>):Void

Shows the number of resources loaded by the game of the given types.

@:native("PrintResourcesInUse")staticprintResourcesInUse(?short:Bool):Void

Shows all resources currently used by the game.

@:native("RequestAttention")staticrequestAttention():Void

Request the user attention to the window. It'll flash the taskbar button on Windows or bounce the dock icon on OSX.

Note: This method is implemented on Linux, macOS and Windows.

@:native("RequestPermission")staticrequestPermission(name:String):Bool

At the moment this function is only used by AudioDriverOpenSL to request permission for RECORD_AUDIO on Android.

@:native("RequestPermissions")staticrequestPermissions():Bool

With this function, you can request dangerous permissions since normal permissions are automatically granted at install time in Android applications.

Note: This method is implemented on Android.

@:native("SetBorderlessWindow")staticsetBorderlessWindow(borderless:Bool):Void

@:native("SetClipboard")staticsetClipboard(clipboard:String):Void

@:native("SetCurrentScreen")staticsetCurrentScreen(screen:Int):Void

@:native("SetCurrentTabletDriver")staticsetCurrentTabletDriver(name:String):Void

@:native("SetDeltaSmoothing")staticsetDeltaSmoothing(deltaSmoothingEnabled:Bool):Void

@:native("SetEnvironment")staticsetEnvironment(variable:String, value:String):Bool

Sets the value of the environment variable variable to value. The environment variable will be set for the Godot process and any process executed with godot.OS.execute after running godot.OS.setEnvironment. The environment variable will not persist to processes run after the Godot process was terminated.

Note: Double-check the casing of variable. Environment variable names are case-sensitive on all platforms except Windows.

@:native("SetExitCode")staticsetExitCode(code:Int):Void

@:native("SetIcon")staticsetIcon(icon:Image):Void

Sets the game's icon using an godot.Image resource.

The same image is used for window caption, taskbar/dock and window selection dialog. Image is scaled as needed.

Note: This method is implemented on HTML5, Linux, macOS and Windows.

@:native("SetImeActive")staticsetImeActive(active:Bool):Void

Sets whether IME input mode should be enabled.

If active IME handles key events before the application and creates an composition string and suggestion list.

Application can retrieve the composition status by using godot.OS.getImeSelection and godot.OS.getImeText functions.

Completed composition string is committed when input is finished.

Note: This method is implemented on Linux, macOS and Windows.

@:native("SetImePosition")staticsetImePosition(position:Vector2):Void

Sets position of IME suggestion list popup (in window coordinates).

Note: This method is implemented on Linux, macOS and Windows.

@:native("SetKeepScreenOn")staticsetKeepScreenOn(enabled:Bool):Void

@:native("SetLowProcessorUsageMode")staticsetLowProcessorUsageMode(enable:Bool):Void

@:native("SetLowProcessorUsageModeSleepUsec")staticsetLowProcessorUsageModeSleepUsec(usec:Int):Void

@:native("SetMaxWindowSize")staticsetMaxWindowSize(size:Vector2):Void

@:native("SetMinWindowSize")staticsetMinWindowSize(size:Vector2):Void

@:native("SetNativeIcon")staticsetNativeIcon(filename:String):Void

Sets the game's icon using a multi-size platform-specific icon file (*.ico on Windows and *.icns on macOS).

Appropriate size sub-icons are used for window caption, taskbar/dock and window selection dialog.

Note: This method is implemented on macOS and Windows.

@:native("SetScreenOrientation")staticsetScreenOrientation(orientation:OS_ScreenOrientationEnum):Void

@:native("SetThreadName")staticsetThreadName(name:String):Error

Sets the name of the current thread.

@:native("SetUseFileAccessSaveAndSwap")staticsetUseFileAccessSaveAndSwap(enabled:Bool):Void

Enables backup saves if enabled is true.

@:native("SetUseVsync")staticsetUseVsync(enable:Bool):Void

@:native("SetVsyncViaCompositor")staticsetVsyncViaCompositor(enable:Bool):Void

@:native("SetWindowAlwaysOnTop")staticsetWindowAlwaysOnTop(enabled:Bool):Void

Sets whether the window should always be on top.

Note: This method is implemented on Linux, macOS and Windows.

@:native("SetWindowFullscreen")staticsetWindowFullscreen(enabled:Bool):Void

@:native("SetWindowMaximized")staticsetWindowMaximized(enabled:Bool):Void

@:native("SetWindowMinimized")staticsetWindowMinimized(enabled:Bool):Void

@:native("SetWindowMousePassthrough")staticsetWindowMousePassthrough(region:HaxeArray<Vector2>):Void

Sets a polygonal region of the window which accepts mouse events. Mouse events outside the region will be passed through.

Passing an empty array will disable passthrough support (all mouse events will be intercepted by the window, which is the default behavior).


# Set region, using Path2D node.
OS.set_window_mouse_passthrough($Path2D.curve.get_baked_points())

# Set region, using Polygon2D node.
OS.set_window_mouse_passthrough($Polygon2D.polygon)

# Reset region to default.
OS.set_window_mouse_passthrough([])

Note: On Windows, the portion of a window that lies outside the region is not drawn, while on Linux and macOS it is.

Note: This method is implemented on Linux, macOS and Windows.

@:native("SetWindowPerPixelTransparencyEnabled")staticsetWindowPerPixelTransparencyEnabled(enabled:Bool):Void

@:native("SetWindowPosition")staticsetWindowPosition(position:Vector2):Void

@:native("SetWindowResizable")staticsetWindowResizable(enabled:Bool):Void

@:native("SetWindowSize")staticsetWindowSize(size:Vector2):Void

@:native("SetWindowTitle")staticsetWindowTitle(title:String):Void

Sets the window title to the specified string.

Note: This should be used sporadically. Don't set this every frame, as that will negatively affect performance on some window managers.

Note: This method is implemented on HTML5, Linux, macOS and Windows.

@:native("ShellOpen")staticshellOpen(uri:String):Error

Requests the OS to open a resource with the most appropriate program. For example:

Use godot.ProjectSettings.globalizePath to convert a res:// or user:// path into a system path for use with this method.

Note: This method is implemented on Android, iOS, HTML5, Linux, macOS and Windows.

@:native("ShowVirtualKeyboard")staticshowVirtualKeyboard(?existingText:String, ?multiline:Bool):Void

Shows the virtual keyboard if the platform has one.

The existing_text parameter is useful for implementing your own godot.LineEdit or godot.TextEdit, as it tells the virtual keyboard what text has already been typed (the virtual keyboard uses it for auto-correct and predictions).

The multiline parameter needs to be set to true to be able to enter multiple lines of text, as in godot.TextEdit.

Note: This method is implemented on Android, iOS and UWP.