Debian Codegraph @

doc/classes/OS.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="OS" inherits="Object" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 Provides access to common operating system functionalities.
5 </brief_description>
6 <description>
7 The [OS] class wraps the most common functionalities for communicating with the host operating system, such as the video driver, delays, environment variables, execution of binaries, command line, etc.
8 [b]Note:[/b] In Godot 4, [OS] functions related to window management, clipboard, and TTS were moved to the [DisplayServer] singleton (and the [Window] class). Functions related to time were removed and are only available in the [Time] class.
9 </description>
10 <tutorials>
11 <link title="Operating System Testing Demo">https://godotengine.org/asset-library/asset/2789</link>
12 </tutorials>
13 <methods>
14 <method name="add_logger">
15 <return type="void" />
16 <param index="0" name="logger" type="Logger" />
17 <description>
18 Add a custom logger to intercept the internal message stream.
19 </description>
20 </method>
21 <method name="alert">
22 <return type="void" />
23 <param index="0" name="text" type="String" />
24 <param index="1" name="title" type="String" default="&quot;Alert!&quot;" />
25 <description>
26 Displays a modal dialog box using the host platform's implementation. The engine execution is blocked until the dialog is closed.
27 </description>
28 </method>
29 <method name="close_midi_inputs">
30 <return type="void" />
31 <description>
32 Shuts down the system MIDI driver. Godot will no longer receive [InputEventMIDI]. See also [method open_midi_inputs] and [method get_connected_midi_inputs].
33 [b]Note:[/b] This method is implemented on Linux, macOS, Windows, and Web.
34 </description>
35 </method>
36 <method name="crash">
37 <return type="void" />
38 <param index="0" name="message" type="String" />
39 <description>
40 Crashes the engine (or the editor if called within a [code]@tool[/code] script). See also [method kill].
41 [b]Note:[/b] This method should [i]only[/i] be used for testing the system's crash handler, not for any other purpose. For general error reporting, use (in order of preference) [method @GDScript.assert], [method @GlobalScope.push_error], or [method alert].
42 </description>
43 </method>
44 <method name="create_instance">
45 <return type="int" />
46 <param index="0" name="arguments" type="PackedStringArray" />
47 <description>
48 Creates a new instance of Godot that runs independently. The [param arguments] are used in the given order and separated by a space.
49 If the process is successfully created, this method returns the new process' ID, which you can use to monitor the process (and potentially terminate it with [method kill]). If the process cannot be created, this method returns [code]-1[/code].
50 See [method create_process] if you wish to run a different process.
51 [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows.
52 </description>
53 </method>
54 <method name="create_process">
55 <return type="int" />
56 <param index="0" name="path" type="String" />
57 <param index="1" name="arguments" type="PackedStringArray" />
58 <param index="2" name="open_console" type="bool" default="false" />
59 <description>
60 Creates a new process that runs independently of Godot. It will not terminate when Godot terminates. The path specified in [param path] must exist and be an executable file or macOS [code].app[/code] bundle. The path is resolved based on the current platform. The [param arguments] are used in the given order and separated by a space.
61 On Windows, if [param open_console] is [code]true[/code] and the process is a console app, a new terminal window will be opened.
62 If the process is successfully created, this method returns its process ID, which you can use to monitor the process (and potentially terminate it with [method kill]). Otherwise, this method returns [code]-1[/code].
63 [b]Example:[/b] Run another instance of the project:
64 [codeblocks]
65 [gdscript]
66 var pid = OS.create_process(OS.get_executable_path(), [])
67 [/gdscript]
68 [csharp]
69 var pid = OS.CreateProcess(OS.GetExecutablePath(), []);
70 [/csharp]
71 [/codeblocks]
72 See [method execute] if you wish to run an external command and retrieve the results.
73 [b]Note:[/b] This method is implemented on Android, Linux, macOS, and Windows.
74 [b]Note:[/b] On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export or system .app bundle, system .app bundles will ignore arguments.
75 </description>
76 </method>
77 <method name="delay_msec" qualifiers="const">
78 <return type="void" />
79 <param index="0" name="msec" type="int" />
80 <description>
81 Delays execution of the current thread by [param msec] milliseconds. [param msec] must be greater than or equal to [code]0[/code]. Otherwise, [method delay_msec] does nothing and prints an error message.
82 [b]Note:[/b] [method delay_msec] is a [i]blocking[/i] way to delay code execution. To delay code execution in a non-blocking way, you may use [method SceneTree.create_timer]. Awaiting with [SceneTreeTimer] delays the execution of code placed below the [code]await[/code] without affecting the rest of the project (or editor, for [EditorPlugin]s and [EditorScript]s).
83 [b]Note:[/b] When [method delay_msec] 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 [method delay_msec] as part of an [EditorPlugin] or [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).
84 </description>
85 </method>
86 <method name="delay_usec" qualifiers="const">
87 <return type="void" />
88 <param index="0" name="usec" type="int" />
89 <description>
90 Delays execution of the current thread by [param usec] microseconds. [param usec] must be greater than or equal to [code]0[/code]. Otherwise, [method delay_usec] does nothing and prints an error message.
91 [b]Note:[/b] [method delay_usec] is a [i]blocking[/i] way to delay code execution. To delay code execution in a non-blocking way, you may use [method SceneTree.create_timer]. Awaiting with a [SceneTreeTimer] delays the execution of code placed below the [code]await[/code] without affecting the rest of the project (or editor, for [EditorPlugin]s and [EditorScript]s).
92 [b]Note:[/b] When [method delay_usec] 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 [method delay_usec] as part of an [EditorPlugin] or [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).
93 </description>
94 </method>
95 <method name="execute">
96 <return type="int" />
97 <param index="0" name="path" type="String" />
98 <param index="1" name="arguments" type="PackedStringArray" />
99 <param index="2" name="output" type="Array" default="[]" />
100 <param index="3" name="read_stderr" type="bool" default="false" />
101 <param index="4" name="open_console" type="bool" default="false" />
102 <description>
103 Executes the given process in a [i]blocking[/i] way. The file specified in [param path] must exist and be executable. The system path resolution will be used. The [param arguments] are used in the given order, separated by spaces, and wrapped in quotes.
104 If an [param output] array is provided, the complete shell output of the process is appended to [param output] as a single [String] element. If [param read_stderr] is [code]true[/code], the output to the standard error stream is also appended to the array.
105 On Windows, if [param open_console] is [code]true[/code] and the process is a console app, a new terminal window is opened.
106 This method returns the exit code of the command, or [code]-1[/code] if the process fails to execute.
107 [b]Note:[/b] The main thread will be blocked until the executed command terminates. Use [Thread] to create a separate thread that will not block the main thread, or use [method create_process] to create a completely independent process.
108 For example, to retrieve a list of the working directory's contents:
109 [codeblocks]
110 [gdscript]
111 var output = []
112 var exit_code = OS.execute("ls", ["-l", "/tmp"], output)
113 [/gdscript]
114 [csharp]
115 Godot.Collections.Array output = [];
116 int exitCode = OS.Execute("ls", ["-l", "/tmp"], output);
117 [/csharp]
118 [/codeblocks]
119 If you wish to access a shell built-in or execute a composite command, a platform-specific shell can be invoked. For example:
120 [codeblocks]
121 [gdscript]
122 var output = []
123 OS.execute("CMD.exe", ["/C", "cd %TEMP% &amp;&amp; dir"], output)
124 [/gdscript]
125 [csharp]
126 Godot.Collections.Array output = [];
127 OS.Execute("CMD.exe", ["/C", "cd %TEMP% &amp;&amp; dir"], output);
128 [/csharp]
129 [/codeblocks]
130 [b]Note:[/b] This method is implemented on Android, Linux, macOS, and Windows.
131 [b]Note:[/b] To execute a Windows command interpreter built-in command, specify [code]cmd.exe[/code] in [param path], [code]/c[/code] as the first argument, and the desired command as the second argument.
132 [b]Note:[/b] To execute a PowerShell built-in command, specify [code]powershell.exe[/code] in [param path], [code]-Command[/code] as the first argument, and the desired command as the second argument.
133 [b]Note:[/b] To execute a Unix shell built-in command, specify shell executable name in [param path], [code]-c[/code] as the first argument, and the desired command as the second argument.
134 [b]Note:[/b] On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export.
135 [b]Note:[/b] On Android, system commands such as [code]dumpsys[/code] can only be run on a rooted device.
136 </description>
137 </method>
138 <method name="execute_with_pipe">
139 <return type="Dictionary" />
140 <param index="0" name="path" type="String" />
141 <param index="1" name="arguments" type="PackedStringArray" />
142 <param index="2" name="blocking" type="bool" default="true" />
143 <description>
144 Creates a new process that runs independently of Godot with redirected IO. It will not terminate when Godot terminates. The path specified in [param path] must exist and be an executable file or macOS [code].app[/code] bundle. The path is resolved based on the current platform. The [param arguments] are used in the given order and separated by a space.
145 If [param blocking] is [code]false[/code], created pipes work in non-blocking mode, i.e. read and write operations will return immediately. Use [method FileAccess.get_error] to check if the last read/write operation was successful.
146 If the process cannot be created, this method returns an empty [Dictionary]. Otherwise, this method returns a [Dictionary] with the following keys:
147 - [code]"stdio"[/code] - [FileAccess] to access the process stdin and stdout pipes (read/write).
148 - [code]"stderr"[/code] - [FileAccess] to access the process stderr pipe (read only).
149 - [code]"pid"[/code] - Process ID as an [int], which you can use to monitor the process (and potentially terminate it with [method kill]).
150 [b]Note:[/b] This method is implemented on Android, Linux, macOS, and Windows.
151 [b]Note:[/b] To execute a Windows command interpreter built-in command, specify [code]cmd.exe[/code] in [param path], [code]/c[/code] as the first argument, and the desired command as the second argument.
152 [b]Note:[/b] To execute a PowerShell built-in command, specify [code]powershell.exe[/code] in [param path], [code]-Command[/code] as the first argument, and the desired command as the second argument.
153 [b]Note:[/b] To execute a Unix shell built-in command, specify shell executable name in [param path], [code]-c[/code] as the first argument, and the desired command as the second argument.
154 [b]Note:[/b] On macOS, sandboxed applications are limited to run only embedded helper executables, specified during export or system .app bundle, system .app bundles will ignore arguments.
155 </description>
156 </method>
157 <method name="find_keycode_from_string" qualifiers="const">
158 <return type="int" enum="Key" />
159 <param index="0" name="string" type="String" />
160 <description>
161 Finds the keycode for the given string. The returned values are equivalent to the [enum Key] constants.
162 [codeblocks]
163 [gdscript]
164 print(OS.find_keycode_from_string("C")) # Prints 67 (KEY_C)
165 print(OS.find_keycode_from_string("Escape")) # Prints 4194305 (KEY_ESCAPE)
166 print(OS.find_keycode_from_string("Shift+Tab")) # Prints 37748738 (KEY_MASK_SHIFT | KEY_TAB)
167 print(OS.find_keycode_from_string("Unknown")) # Prints 0 (KEY_NONE)
168 [/gdscript]
169 [csharp]
170 GD.Print(OS.FindKeycodeFromString("C")); // Prints C (Key.C)
171 GD.Print(OS.FindKeycodeFromString("Escape")); // Prints Escape (Key.Escape)
172 GD.Print(OS.FindKeycodeFromString("Shift+Tab")); // Prints 37748738 (KeyModifierMask.MaskShift | Key.Tab)
173 GD.Print(OS.FindKeycodeFromString("Unknown")); // Prints None (Key.None)
174 [/csharp]
175 [/codeblocks]
176 See also [method get_keycode_string].
177 </description>
178 </method>
179 <method name="get_cache_dir" qualifiers="const">
180 <return type="String" />
181 <description>
182 Returns the [i]global[/i] cache data directory according to the operating system's standards.
183 On the Linux/BSD platform, this path can be overridden by setting the [code]XDG_CACHE_HOME[/code] environment variable before starting the project. See [url=$DOCS_URL/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_config_dir] and [method get_data_dir].
184 Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
185 </description>
186 </method>
187 <method name="get_cmdline_args">
188 <return type="PackedStringArray" />
189 <description>
190 Returns the command-line arguments passed to the engine, excluding arguments processed by the engine, such as [code]--headless[/code] and [code]--fullscreen[/code].
191 [codeblock]
192 # Godot has been executed with the following command:
193 # godot --headless --verbose --scene my_scene.tscn --custom
194 OS.get_cmdline_args() # Returns ["--scene", "my_scene.tscn", "--custom"]
195 [/codeblock]
196 Command-line arguments can be written in any form, including both [code]--key value[/code] and [code]--key=value[/code] forms so they can be properly parsed, as long as custom command-line arguments do not conflict with engine arguments.
197 You can also incorporate environment variables using the [method get_environment] method.
198 You can set [member ProjectSettings.editor/run/main_run_args] to define command-line arguments to be passed by the editor when running the project.
199 [b]Example:[/b] Parse command-line arguments into a [Dictionary] using the [code]--key=value[/code] form for arguments:
200 [codeblocks]
201 [gdscript]
202 var arguments = {}
203 for argument in OS.get_cmdline_args():
204 if argument.contains("="):
205 var key_value = argument.split("=")
206 arguments[key_value[0].trim_prefix("--")] = key_value[1]
207 else:
208 # Options without an argument will be present in the dictionary,
209 # with the value set to an empty string.
210 arguments[argument.trim_prefix("--")] = ""
211 [/gdscript]
212 [csharp]
213 var arguments = new Dictionary&lt;string, string&gt;();
214 foreach (var argument in OS.GetCmdlineArgs())
215 {
216 if (argument.Contains('='))
217 {
218 string[] keyValue = argument.Split("=");
219 arguments[keyValue[0].TrimPrefix("--")] = keyValue[1];
220 }
221 else
222 {
223 // Options without an argument will be present in the dictionary,
224 // with the value set to an empty string.
225 arguments[argument.TrimPrefix("--")] = "";
226 }
227 }
228 [/csharp]
229 [/codeblocks]
230 [b]Note:[/b] Passing custom user arguments directly is not recommended, as the engine may discard or modify them. Instead, pass the standard UNIX double dash ([code]--[/code]) and then the custom arguments, which the engine will ignore by design. These can be read via [method get_cmdline_user_args].
231 </description>
232 </method>
233 <method name="get_cmdline_user_args">
234 <return type="PackedStringArray" />
235 <description>
236 Returns the command-line user arguments passed to the engine. User arguments are ignored by the engine and reserved for the user. They are passed after the double dash [code]--[/code] argument. [code]++[/code] may be used when [code]--[/code] is intercepted by another program (such as [code]startx[/code]).
237 [codeblock]
238 # Godot has been executed with the following command:
239 # godot --fullscreen --custom -- --level=2 --hardcore
240
241 OS.get_cmdline_args() # Returns ["--custom"]
242 OS.get_cmdline_user_args() # Returns ["--level=2", "--hardcore"]
243 [/codeblock]
244 To get arguments passed before [code]--[/code] or [code]++[/code], use [method get_cmdline_args].
245 </description>
246 </method>
247 <method name="get_config_dir" qualifiers="const">
248 <return type="String" />
249 <description>
250 Returns the [i]global[/i] user configuration directory according to the operating system's standards.
251 On the Linux/BSD platform, this path can be overridden by setting the [code]XDG_CONFIG_HOME[/code] environment variable before starting the project. See [url=$DOCS_URL/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_data_dir].
252 Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
253 </description>
254 </method>
255 <method name="get_connected_midi_inputs">
256 <return type="PackedStringArray" />
257 <description>
258 Returns an array of connected MIDI device names, if they exist. Returns an empty array if the system MIDI driver has not previously been initialized with [method open_midi_inputs]. See also [method close_midi_inputs].
259 [b]Note:[/b] This method is implemented on Linux, macOS, Windows, and Web.
260 [b]Note:[/b] On the Web platform, Web MIDI needs to be supported by the browser. [url=https://caniuse.com/midi]For the time being[/url], it is currently supported by all major browsers, except Safari.
261 [b]Note:[/b] On the Web platform, using MIDI input requires a browser permission to be granted first. This permission request is performed when calling [method open_midi_inputs]. The browser will refrain from processing MIDI input until the user accepts the permission request.
262 </description>
263 </method>
264 <method name="get_data_dir" qualifiers="const">
265 <return type="String" />
266 <description>
267 Returns the [i]global[/i] user data directory according to the operating system's standards.
268 On the Linux/BSD platform, this path can be overridden by setting the [code]XDG_DATA_HOME[/code] environment variable before starting the project. See [url=$DOCS_URL/tutorials/io/data_paths.html]File paths in Godot projects[/url] in the documentation for more information. See also [method get_cache_dir] and [method get_config_dir].
269 Not to be confused with [method get_user_data_dir], which returns the [i]project-specific[/i] user data path.
270 </description>
271 </method>
272 <method name="get_distribution_name" qualifiers="const">
273 <return type="String" />
274 <description>
275 Returns the name of the distribution for Linux and BSD platforms (e.g. "Ubuntu", "Manjaro", "OpenBSD", etc.).
276 Returns the same value as [method get_name] for stock Android ROMs, but attempts to return the custom ROM name for popular Android derivatives such as "LineageOS".
277 Returns the same value as [method get_name] for other platforms.
278 [b]Note:[/b] This method is not supported on the Web platform. It returns an empty string.
279 </description>
280 </method>
281 <method name="get_entropy">
282 <return type="PackedByteArray" />
283 <param index="0" name="size" type="int" />
284 <description>
285 Generates a [PackedByteArray] of cryptographically secure random bytes with given [param size].
286 [b]Note:[/b] Generating large quantities of bytes using this method can result in locking and entropy of lower quality on most platforms. Using [method Crypto.generate_random_bytes] is preferred in most cases.
287 </description>
288 </method>
289 <method name="get_environment" qualifiers="const">
290 <return type="String" />
291 <param index="0" name="variable" type="String" />
292 <description>
293 Returns the value of the given environment variable, or an empty string if [param variable] doesn't exist.
294 [b]Note:[/b] Double-check the casing of [param variable]. Environment variable names are case-sensitive on all platforms except Windows.
295 [b]Note:[/b] On macOS, applications do not have access to shell environment variables.
296 </description>
297 </method>
298 <method name="get_executable_path" qualifiers="const">
299 <return type="String" />
300 <description>
301 Returns the file path to the current engine executable.
302 [b]Note:[/b] On macOS, if you want to launch another instance of Godot, always use [method create_instance] instead of relying on the executable path.
303 </description>
304 </method>
305 <method name="get_granted_permissions" qualifiers="const">
306 <return type="PackedStringArray" />
307 <description>
308 On Android devices: Returns the list of dangerous permissions that have been granted.
309 On macOS: Returns the list of granted permissions and user selected folders accessible to the application (sandboxed applications only). Use the native file dialog to request folder access permission.
310 On iOS, visionOS: Returns the list of granted permissions.
311 </description>
312 </method>
313 <method name="get_keycode_string" qualifiers="const">
314 <return type="String" />
315 <param index="0" name="code" type="int" enum="Key" />
316 <description>
317 Returns the given keycode as a [String].
318 [codeblocks]
319 [gdscript]
320 print(OS.get_keycode_string(KEY_C)) # Prints "C"
321 print(OS.get_keycode_string(KEY_ESCAPE)) # Prints "Escape"
322 print(OS.get_keycode_string(KEY_MASK_SHIFT | KEY_TAB)) # Prints "Shift+Tab"
323 [/gdscript]
324 [csharp]
325 GD.Print(OS.GetKeycodeString(Key.C)); // Prints "C"
326 GD.Print(OS.GetKeycodeString(Key.Escape)); // Prints "Escape"
327 GD.Print(OS.GetKeycodeString((Key)KeyModifierMask.MaskShift | Key.Tab)); // Prints "Shift+Tab"
328 [/csharp]
329 [/codeblocks]
330 See also [method find_keycode_from_string], [member InputEventKey.keycode], and [method InputEventKey.get_keycode_with_modifiers].
331 </description>
332 </method>
333 <method name="get_locale" qualifiers="const">
334 <return type="String" />
335 <description>
336 Returns the host OS locale as a [String] of the form [code]language_Script_COUNTRY_VARIANT@extra[/code]. Every substring after [code]language[/code] is optional and may not exist.
337 - [code]language[/code] - 2 or 3-letter [url=https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes]language code[/url], in lower case.
338 - [code skip-lint]Script[/code] - 4-letter [url=https://en.wikipedia.org/wiki/ISO_15924]script code[/url], in title case.
339 - [code]COUNTRY[/code] - 2 or 3-letter [url=https://en.wikipedia.org/wiki/ISO_3166-1]country code[/url], in upper case.
340 - [code]VARIANT[/code] - language variant, region and sort order. The variant can have any number of underscored keywords.
341 - [code]extra[/code] - semicolon separated list of additional key words. This may include currency, calendar, sort order and numbering system information.
342 If you want only the language code and not the fully specified locale from the OS, you can use [method get_locale_language].
343 </description>
344 </method>
345 <method name="get_locale_language" qualifiers="const">
346 <return type="String" />
347 <description>
348 Returns the host OS locale's 2 or 3-letter [url=https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes]language code[/url] as a string which should be consistent on all platforms. This is equivalent to extracting the [code]language[/code] part of the [method get_locale] string.
349 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 [code]fr_CA[/code] locale, this would return [code]fr[/code].
350 </description>
351 </method>
352 <method name="get_main_thread_id" qualifiers="const">
353 <return type="int" />
354 <description>
355 Returns the ID of the main thread. See [method get_thread_caller_id].
356 [b]Note:[/b] Thread IDs are not deterministic and may be reused across application restarts.
357 </description>
358 </method>
359 <method name="get_memory_info" qualifiers="const">
360 <return type="Dictionary" />
361 <description>
362 Returns a [Dictionary] containing information about the current memory with the following entries:
363 - [code]"physical"[/code] - total amount of usable physical memory in bytes. This value can be slightly less than the actual physical memory amount, since it does not include memory reserved by the kernel and devices.
364 - [code]"free"[/code] - amount of physical memory, that can be immediately allocated without disk access or other costly operations, in bytes. The process might be able to allocate more physical memory, but this action will require moving inactive pages to disk, which can be expensive.
365 - [code]"available"[/code] - amount of memory that can be allocated without extending the swap file(s), in bytes. This value includes both physical memory and swap.
366 - [code]"stack"[/code] - size of the current thread stack in bytes.
367 [b]Note:[/b] Each entry's value may be [code]-1[/code] if it is unknown.
368 </description>
369 </method>
370 <method name="get_model_name" qualifiers="const">
371 <return type="String" />
372 <description>
373 Returns the model name of the current device.
374 [b]Note:[/b] This method is implemented on Android, iOS, macOS, and Windows. Returns [code]"GenericDevice"[/code] on unsupported platforms.
375 </description>
376 </method>
377 <method name="get_name" qualifiers="const">
378 <return type="String" />
379 <description>
380 Returns the name of the host platform.
381 - On Windows, this is [code]"Windows"[/code].
382 - On macOS, this is [code]"macOS"[/code].
383 - On Linux-based operating systems, this is [code]"Linux"[/code].
384 - On BSD-based operating systems, this is [code]"FreeBSD"[/code], [code]"NetBSD"[/code], [code]"OpenBSD"[/code], or [code]"BSD"[/code] as a fallback.
385 - On Android, this is [code]"Android"[/code].
386 - On iOS, this is [code]"iOS"[/code].
387 - On Web, this is [code]"Web"[/code].
388 [b]Note:[/b] Custom builds of the engine may support additional platforms, such as consoles, possibly returning other names.
389 [codeblocks]
390 [gdscript]
391 match OS.get_name():
392 "Windows":
393 print("Welcome to Windows!")
394 "macOS":
395 print("Welcome to macOS!")
396 "Linux", "FreeBSD", "NetBSD", "OpenBSD", "BSD":
397 print("Welcome to Linux/BSD!")
398 "Android":
399 print("Welcome to Android!")
400 "iOS":
401 print("Welcome to iOS!")
402 "Web":
403 print("Welcome to the Web!")
404 [/gdscript]
405 [csharp]
406 switch (OS.GetName())
407 {
408 case "Windows":
409 GD.Print("Welcome to Windows");
410 break;
411 case "macOS":
412 GD.Print("Welcome to macOS!");
413 break;
414 case "Linux":
415 case "FreeBSD":
416 case "NetBSD":
417 case "OpenBSD":
418 case "BSD":
419 GD.Print("Welcome to Linux/BSD!");
420 break;
421 case "Android":
422 GD.Print("Welcome to Android!");
423 break;
424 case "iOS":
425 GD.Print("Welcome to iOS!");
426 break;
427 case "Web":
428 GD.Print("Welcome to the Web!");
429 break;
430 }
431 [/csharp]
432 [/codeblocks]
433 [b]Note:[/b] On Web platforms, it is still possible to determine the host platform's OS with feature tags. See [method has_feature].
434 </description>
435 </method>
436 <method name="get_process_exit_code" qualifiers="const">
437 <return type="int" />
438 <param index="0" name="pid" type="int" />
439 <description>
440 Returns the exit code of a spawned process once it has finished running (see [method is_process_running]).
441 Returns [code]-1[/code] if the [param pid] is not a PID of a spawned child process, the process is still running, or the method is not implemented for the current platform.
442 [b]Note:[/b] Returns [code]-1[/code] if the [param pid] is a macOS bundled app process.
443 [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows.
444 </description>
445 </method>
446 <method name="get_process_id" qualifiers="const">
447 <return type="int" />
448 <description>
449 Returns the number used by the host machine to uniquely identify this application.
450 [b]Note:[/b] On Web, this method always returns [code]0[/code].
451 </description>
452 </method>
453 <method name="get_processor_count" qualifiers="const">
454 <return type="int" />
455 <description>
456 Returns the number of [i]logical[/i] CPU cores available on the host machine. On CPUs with HyperThreading enabled, this number will be greater than the number of [i]physical[/i] CPU cores.
457 </description>
458 </method>
459 <method name="get_processor_name" qualifiers="const">
460 <return type="String" />
461 <description>
462 Returns the full name of the CPU model on the host machine (e.g. [code]"Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz"[/code]).
463 [b]Note:[/b] This method is only implemented on Windows, macOS, Linux and iOS. On Android and Web, [method get_processor_name] returns an empty string.
464 </description>
465 </method>
466 <method name="get_restart_on_exit_arguments" qualifiers="const">
467 <return type="PackedStringArray" />
468 <description>
469 Returns the list of command line arguments that will be used when the project automatically restarts using [method set_restart_on_exit]. See also [method is_restart_on_exit_set].
470 </description>
471 </method>
472 <method name="get_static_memory_peak_usage" qualifiers="const">
473 <return type="int" />
474 <description>
475 Returns the maximum amount of static memory used. Only works in debug builds.
476 </description>
477 </method>
478 <method name="get_static_memory_usage" qualifiers="const">
479 <return type="int" />
480 <description>
481 Returns the amount of static memory being used by the program in bytes. Only works in debug builds.
482 </description>
483 </method>
484 <method name="get_stderr_type" qualifiers="const">
485 <return type="int" enum="OS.StdHandleType" />
486 <description>
487 Returns the type of the standard error device.
488 [b]Note:[/b] This method is implemented on Linux, macOS, and Windows.
489 </description>
490 </method>
491 <method name="get_stdin_type" qualifiers="const">
492 <return type="int" enum="OS.StdHandleType" />
493 <description>
494 Returns the type of the standard input device.
495 [b]Note:[/b] This method is implemented on Linux, macOS, and Windows.
496 [b]Note:[/b] On exported Windows builds, run the console wrapper executable to access the standard input. If you need a single executable with full console support, use a custom build compiled with the [code]windows_subsystem=console[/code] flag.
497 </description>
498 </method>
499 <method name="get_stdout_type" qualifiers="const">
500 <return type="int" enum="OS.StdHandleType" />
501 <description>
502 Returns the type of the standard output device.
503 [b]Note:[/b] This method is implemented on Linux, macOS, and Windows.
504 </description>
505 </method>
506 <method name="get_system_ca_certificates">
507 <return type="String" />
508 <description>
509 Returns the list of certification authorities trusted by the operating system as a string of concatenated certificates in PEM format.
510 </description>
511 </method>
512 <method name="get_system_dir" qualifiers="const">
513 <return type="String" />
514 <param index="0" name="dir" type="int" enum="OS.SystemDir" />
515 <param index="1" name="shared_storage" type="bool" default="true" />
516 <description>
517 Returns the path to commonly used folders across different platforms, as defined by [param dir]. See the [enum SystemDir] constants for available locations.
518 [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows.
519 [b]Note:[/b] Shared storage is implemented on Android and allows to differentiate between app specific and shared directories, if [param shared_storage] is [code]true[/code]. Shared directories have additional restrictions on Android.
520 </description>
521 </method>
522 <method name="get_system_font_path" qualifiers="const">
523 <return type="String" />
524 <param index="0" name="font_name" type="String" />
525 <param index="1" name="weight" type="int" default="400" />
526 <param index="2" name="stretch" type="int" default="100" />
527 <param index="3" name="italic" type="bool" default="false" />
528 <description>
529 Returns the path to the system font file with [param font_name] and style. Returns an empty string if no matching fonts found.
530 The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
531 [b]Note:[/b] Returned font might have different style if the requested style is not available.
532 [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
533 </description>
534 </method>
535 <method name="get_system_font_path_for_text" qualifiers="const">
536 <return type="PackedStringArray" />
537 <param index="0" name="font_name" type="String" />
538 <param index="1" name="text" type="String" />
539 <param index="2" name="locale" type="String" default="&quot;&quot;" />
540 <param index="3" name="script" type="String" default="&quot;&quot;" />
541 <param index="4" name="weight" type="int" default="400" />
542 <param index="5" name="stretch" type="int" default="100" />
543 <param index="6" name="italic" type="bool" default="false" />
544 <description>
545 Returns an array of the system substitute font file paths, which are similar to the font with [param font_name] and style for the specified text, locale, and script. Returns an empty array if no matching fonts found.
546 The following aliases can be used to request default fonts: "sans-serif", "serif", "monospace", "cursive", and "fantasy".
547 [b]Note:[/b] Depending on OS, it's not guaranteed that any of the returned fonts will be suitable for rendering specified text. Fonts should be loaded and checked in the order they are returned, and the first suitable one used.
548 [b]Note:[/b] Returned fonts might have different style if the requested style is not available or belong to a different font family.
549 [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
550 </description>
551 </method>
552 <method name="get_system_fonts" qualifiers="const">
553 <return type="PackedStringArray" />
554 <description>
555 Returns the list of font family names available.
556 [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
557 </description>
558 </method>
559 <method name="get_temp_dir" qualifiers="const">
560 <return type="String" />
561 <description>
562 Returns the [i]global[/i] temporary data directory according to the operating system's standards.
563 </description>
564 </method>
565 <method name="get_thread_caller_id" qualifiers="const">
566 <return type="int" />
567 <description>
568 Returns the ID of the current thread. This can be used in logs to ease debugging of multi-threaded applications.
569 [b]Note:[/b] Thread IDs are not deterministic and may be reused across application restarts.
570 </description>
571 </method>
572 <method name="get_unique_id" qualifiers="const">
573 <return type="String" />
574 <description>
575 Returns a string that is unique to the device.
576 [b]Note:[/b] This string may change without notice if the user reinstalls their operating system, upgrades it, or modifies 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 this method for security purposes.
577 [b]Note:[/b] On Web, returns an empty string and generates an error, as this method cannot be implemented for security reasons.
578 </description>
579 </method>
580 <method name="get_user_data_dir" qualifiers="const">
581 <return type="String" />
582 <description>
583 Returns the absolute directory path where user data is written (the [code]user://[/code] directory in Godot). The path depends on the project name and [member ProjectSettings.application/config/use_custom_user_dir].
584 - On Windows, this is [code]%AppData%\Godot\app_userdata\[project_name][/code], or [code]%AppData%\[custom_name][/code] if [code]use_custom_user_dir[/code] is set. [code]%AppData%[/code] expands to [code]%UserProfile%\AppData\Roaming[/code].
585 - On macOS, this is [code]~/Library/Application Support/Godot/app_userdata/[project_name][/code], or [code]~/Library/Application Support/[custom_name][/code] if [code]use_custom_user_dir[/code] is set.
586 - On Linux and BSD, this is [code]~/.local/share/godot/app_userdata/[project_name][/code], or [code]~/.local/share/[custom_name][/code] if [code]use_custom_user_dir[/code] is set.
587 - On Android and iOS, this is a sandboxed directory in either internal or external storage, depending on the user's configuration.
588 - On Web, this is a virtual directory managed by the browser.
589 If the project name is empty, [code][project_name][/code] falls back to [code][unnamed project][/code].
590 Not to be confused with [method get_data_dir], which returns the [i]global[/i] (non-project-specific) user home directory.
591 </description>
592 </method>
593 <method name="get_version" qualifiers="const">
594 <return type="String" />
595 <description>
596 Returns the exact production and build version of the operating system. This is different from the branded version used in marketing. This helps to distinguish between different releases of operating systems, including minor versions, and insider and custom builds.
597 - For Windows, the major and minor version are returned, as well as the build number. For example, the returned string may look like [code]10.0.9926[/code] for a build of Windows 10.
598 - For rolling distributions, such as Arch Linux, an empty string is returned.
599 - For macOS and iOS, the major and minor version are returned, as well as the patch number.
600 - For Android, the SDK version and the incremental build number are returned. If it's a custom ROM, it attempts to return its version instead.
601 [b]Note:[/b] This method is not supported on the Web platform. It returns an empty string.
602 </description>
603 </method>
604 <method name="get_version_alias" qualifiers="const">
605 <return type="String" />
606 <description>
607 Returns the branded version used in marketing, followed by the build number (on Windows), the version number (on macOS), or the SDK version and incremental build number (on Android). Examples include [code]11 (build 22000)[/code], [code]Sequoia (15.0.0)[/code], and [code]15 (SDK 35 build abc528-11988f)[/code].
608 This value can then be appended to [method get_name] to get a full, human-readable operating system name and version combination for the operating system. Windows feature updates such as 24H2 are not contained in the resulting string, but Windows Server is recognized as such (e.g. [code]2025 (build 26100)[/code] for Windows Server 2025).
609 [b]Note:[/b] This method is only supported on Windows, macOS, and Android. On other operating systems, it returns the same value as [method get_version].
610 </description>
611 </method>
612 <method name="get_video_adapter_driver_info" qualifiers="const">
613 <return type="PackedStringArray" />
614 <description>
615 Returns the video adapter driver name and version for the user's currently active graphics card, as a [PackedStringArray]. See also [method RenderingServer.get_video_adapter_api_version].
616 The first element holds the driver name, such as [code]nvidia[/code], [code]amdgpu[/code], etc.
617 The second element holds the driver version. For example, on the [code]nvidia[/code] driver on a Linux/BSD platform, the version is in the format [code]510.85.02[/code]. For Windows, the driver's format is [code]31.0.15.1659[/code].
618 [b]Note:[/b] This method is only supported on Linux/BSD and Windows when not running in headless mode. On other platforms, it returns an empty array.
619 [b]Note:[/b] This method will run slowly the first time it is called in a session; it can take several seconds depending on the operating system and hardware. It is blocking if called on the main thread, so it's recommended to call it on a separate thread using [Thread]. This allows the engine to keep running while the information is being retrieved. However, [method get_video_adapter_driver_info] is [i]not[/i] thread-safe, so it should not be called from multiple threads at the same time.
620 [codeblocks]
621 [gdscript]
622 var thread = Thread.new()
623
624 func _ready():
625 thread.start(
626 func():
627 var driver_info = OS.get_video_adapter_driver_info()
628 if not driver_info.is_empty():
629 print("Driver: %s %s" % [driver_info[0], driver_info[1]])
630 else:
631 print("Driver: (unknown)")
632 )
633
634 func _exit_tree():
635 thread.wait_to_finish()
636 [/gdscript]
637 [/codeblocks]
638 </description>
639 </method>
640 <method name="has_environment" qualifiers="const">
641 <return type="bool" />
642 <param index="0" name="variable" type="String" />
643 <description>
644 Returns [code]true[/code] if the environment variable with the name [param variable] exists.
645 [b]Note:[/b] Double-check the casing of [param variable]. Environment variable names are case-sensitive on all platforms except Windows.
646 </description>
647 </method>
648 <method name="has_feature" qualifiers="const">
649 <return type="bool" />
650 <param index="0" name="tag_name" type="String" />
651 <description>
652 Returns [code]true[/code] 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 [url=$DOCS_URL/tutorials/export/feature_tags.html]Feature Tags[/url] documentation for more details.
653 [b]Note:[/b] Tag names are case-sensitive.
654 [b]Note:[/b] On the Web platform, one of the following additional tags is defined to indicate the host platform: [code]web_android[/code], [code]web_ios[/code], [code]web_linuxbsd[/code], [code]web_macos[/code], or [code]web_windows[/code].
655 </description>
656 </method>
657 <method name="is_debug_build" qualifiers="const">
658 <return type="bool" />
659 <description>
660 Returns [code]true[/code] if the Godot binary used to run the project is a [i]debug[/i] export template, or when running in the editor.
661 Returns [code]false[/code] if the Godot binary used to run the project is a [i]release[/i] export template.
662 [b]Note:[/b] To check whether the Godot binary used to run the project is an export template (debug or release), use [code]OS.has_feature("template")[/code] instead.
663 </description>
664 </method>
665 <method name="is_keycode_unicode" qualifiers="const">
666 <return type="bool" />
667 <param index="0" name="code" type="int" />
668 <description>
669 Returns [code]true[/code] if the input keycode corresponds to a Unicode character. For a list of codes, see the [enum Key] constants.
670 [codeblocks]
671 [gdscript]
672 print(OS.is_keycode_unicode(KEY_G)) # Prints true
673 print(OS.is_keycode_unicode(KEY_KP_4)) # Prints true
674 print(OS.is_keycode_unicode(KEY_TAB)) # Prints false
675 print(OS.is_keycode_unicode(KEY_ESCAPE)) # Prints false
676 [/gdscript]
677 [csharp]
678 GD.Print(OS.IsKeycodeUnicode((long)Key.G)); // Prints True
679 GD.Print(OS.IsKeycodeUnicode((long)Key.Kp4)); // Prints True
680 GD.Print(OS.IsKeycodeUnicode((long)Key.Tab)); // Prints False
681 GD.Print(OS.IsKeycodeUnicode((long)Key.Escape)); // Prints False
682 [/csharp]
683 [/codeblocks]
684 </description>
685 </method>
686 <method name="is_process_running" qualifiers="const">
687 <return type="bool" />
688 <param index="0" name="pid" type="int" />
689 <description>
690 Returns [code]true[/code] if the child process ID ([param pid]) is still running or [code]false[/code] if it has terminated. [param pid] must be a valid ID generated from [method create_process].
691 [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS, and Windows.
692 </description>
693 </method>
694 <method name="is_restart_on_exit_set" qualifiers="const">
695 <return type="bool" />
696 <description>
697 Returns [code]true[/code] if the project will automatically restart when it exits for any reason, [code]false[/code] otherwise. See also [method set_restart_on_exit] and [method get_restart_on_exit_arguments].
698 </description>
699 </method>
700 <method name="is_sandboxed" qualifiers="const">
701 <return type="bool" />
702 <description>
703 Returns [code]true[/code] if the application is running in the sandbox.
704 [b]Note:[/b] This method is only implemented on macOS and Linux.
705 </description>
706 </method>
707 <method name="is_stdout_verbose" qualifiers="const">
708 <return type="bool" />
709 <description>
710 Returns [code]true[/code] if the engine was executed with the [code]--verbose[/code] or [code]-v[/code] command line argument, or if [member ProjectSettings.debug/settings/stdout/verbose_stdout] is [code]true[/code]. See also [method @GlobalScope.print_verbose].
711 </description>
712 </method>
713 <method name="is_userfs_persistent" qualifiers="const">
714 <return type="bool" />
715 <description>
716 Returns [code]true[/code] if the [code]user://[/code] file system is persistent, that is, its state is the same after a player quits and starts the game again. Relevant to the Web platform, where this persistence may be unavailable.
717 </description>
718 </method>
719 <method name="kill">
720 <return type="int" enum="Error" />
721 <param index="0" name="pid" type="int" />
722 <description>
723 Kill (terminate) the process identified by the given process ID ([param pid]), such as the ID returned by [method execute] in non-blocking mode. See also [method crash].
724 [b]Note:[/b] This method can also be used to kill processes that were not spawned by the engine.
725 [b]Note:[/b] This method is implemented on Android, iOS, Linux, macOS and Windows.
726 </description>
727 </method>
728 <method name="move_to_trash" qualifiers="const">
729 <return type="int" enum="Error" />
730 <param index="0" name="path" type="String" />
731 <description>
732 Moves the file or directory at the given [param path] to the system's recycle bin. See also [method DirAccess.remove].
733 The method takes only global paths, so you may need to use [method ProjectSettings.globalize_path]. Do not use it for files in [code]res://[/code] as it will not work in exported projects.
734 Returns [constant FAILED] if the file or directory cannot be found, or the system does not support this method.
735 [codeblocks]
736 [gdscript]
737 var file_to_remove = "user://slot1.save"
738 OS.move_to_trash(ProjectSettings.globalize_path(file_to_remove))
739 [/gdscript]
740 [csharp]
741 var fileToRemove = "user://slot1.save";
742 OS.MoveToTrash(ProjectSettings.GlobalizePath(fileToRemove));
743 [/csharp]
744 [/codeblocks]
745 [b]Note:[/b] This method is implemented on Android, Linux, macOS and Windows.
746 [b]Note:[/b] If the user has disabled the recycle bin on their system, the file will be permanently deleted instead.
747 </description>
748 </method>
749 <method name="open_midi_inputs">
750 <return type="void" />
751 <description>
752 Initializes the singleton for the system MIDI driver, allowing Godot to receive [InputEventMIDI]. See also [method get_connected_midi_inputs] and [method close_midi_inputs].
753 [b]Note:[/b] This method is implemented on Linux, macOS, Windows, and Web.
754 [b]Note:[/b] On the Web platform, Web MIDI needs to be supported by the browser. [url=https://caniuse.com/midi]For the time being[/url], it is currently supported by all major browsers, except Safari.
755 [b]Note:[/b] On the Web platform, using MIDI input requires a browser permission to be granted first. This permission request is performed when calling [method open_midi_inputs]. The browser will refrain from processing MIDI input until the user accepts the permission request.
756 </description>
757 </method>
758 <method name="open_with_program">
759 <return type="int" enum="Error" />
760 <param index="0" name="program_path" type="String" />
761 <param index="1" name="paths" type="PackedStringArray" />
762 <description>
763 Opens one or more files/directories with the specified application. The [param program_path] specifies the path to the application to use for opening the files, and [param paths] contains an array of file/directory paths to open.
764 [b]Note:[/b] This method is mostly only relevant for macOS, where opening files using [method create_process] might fail. On other platforms, this falls back to using [method create_process].
765 [b]Note:[/b] On macOS, [param program_path] should ideally be the path to a [code].app[/code] bundle.
766 </description>
767 </method>
768 <method name="read_buffer_from_stdin">
769 <return type="PackedByteArray" />
770 <param index="0" name="buffer_size" type="int" default="1024" />
771 <description>
772 Reads a user input as raw data from the standard input. This operation can be [i]blocking[/i], which causes the window to freeze if [method read_buffer_from_stdin] is called on the main thread.
773 - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]).
774 - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed.
775 - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately.
776 [b]Note:[/b] This method is implemented on Linux, macOS, and Windows.
777 [b]Note:[/b] On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the [code]windows_subsystem=console[/code] flag.
778 </description>
779 </method>
780 <method name="read_string_from_stdin">
781 <return type="String" />
782 <param index="0" name="buffer_size" type="int" default="1024" />
783 <description>
784 Reads a user input as a UTF-8 encoded string from the standard input. This operation can be [i]blocking[/i], which causes the window to freeze if [method read_string_from_stdin] is called on the main thread.
785 - If standard input is console, this method will block until the program receives a line break in standard input (usually by the user pressing [kbd]Enter[/kbd]).
786 - If standard input is pipe, this method will block until a specific amount of data is read or pipe is closed.
787 - If standard input is a file, this method will read a specific amount of data (or less if end-of-file is reached) and return immediately.
788 [b]Note:[/b] This method automatically replaces [code]\r\n[/code] line breaks with [code]\n[/code] and removes them from the end of the string. Use [method read_buffer_from_stdin] to read the unprocessed data.
789 [b]Note:[/b] This method is implemented on Linux, macOS, and Windows.
790 [b]Note:[/b] On exported Windows builds, run the console wrapper executable to access the terminal. If standard input is console, calling this method without console wrapped will freeze permanently. If standard input is pipe or file, it can be used without console wrapper. If you need a single executable with full console support, use a custom build compiled with the [code]windows_subsystem=console[/code] flag.
791 </description>
792 </method>
793 <method name="remove_logger">
794 <return type="void" />
795 <param index="0" name="logger" type="Logger" />
796 <description>
797 Remove a custom logger added by [method add_logger].
798 </description>
799 </method>
800 <method name="request_permission">
801 <return type="bool" />
802 <param index="0" name="name" type="String" />
803 <description>
804 Requests permission from the OS for the given [param name]. Returns [code]true[/code] if the permission has already been granted. See also [signal MainLoop.on_request_permissions_result].
805 The [param name] must be the full permission name. For example:
806 - [code]OS.request_permission("android.permission.READ_EXTERNAL_STORAGE")[/code]
807 - [code]OS.request_permission("android.permission.POST_NOTIFICATIONS")[/code]
808 - [code]OS.request_permission("macos.permission.RECORD_SCREEN")[/code]
809 - [code]OS.request_permission("appleembedded.permission.AUDIO_RECORD")[/code]
810 [b]Note:[/b] On Android, permission must be checked during export.
811 [b]Note:[/b] This method is implemented on Android, macOS, and visionOS platforms.
812 </description>
813 </method>
814 <method name="request_permissions">
815 <return type="bool" />
816 <description>
817 Requests [i]dangerous[/i] permissions from the OS. Returns [code]true[/code] if permissions have already been granted. See also [signal MainLoop.on_request_permissions_result].
818 [b]Note:[/b] Permissions must be checked during export.
819 [b]Note:[/b] This method is only implemented on Android. Normal permissions are automatically granted at install time in Android applications.
820 </description>
821 </method>
822 <method name="revoke_granted_permissions">
823 <return type="void" />
824 <description>
825 On macOS (sandboxed applications only), this function clears list of user selected folders accessible to the application.
826 </description>
827 </method>
828 <method name="set_environment" qualifiers="const">
829 <return type="void" />
830 <param index="0" name="variable" type="String" />
831 <param index="1" name="value" type="String" />
832 <description>
833 Sets the value of the environment variable [param variable] to [param value]. The environment variable will be set for the Godot process and any process executed with [method execute] after running [method set_environment]. The environment variable will [i]not[/i] persist to processes run after the Godot process was terminated.
834 [b]Note:[/b] Environment variable names are case-sensitive on all platforms except Windows. The [param variable] name cannot be empty or include the [code]=[/code] character. On Windows, there is a 32767 characters limit for the combined length of [param variable], [param value], and the [code]=[/code] and null terminator characters that will be registered in the environment block.
835 </description>
836 </method>
837 <method name="set_restart_on_exit">
838 <return type="void" />
839 <param index="0" name="restart" type="bool" />
840 <param index="1" name="arguments" type="PackedStringArray" default="PackedStringArray()" />
841 <description>
842 If [param restart] is [code]true[/code], restarts the project automatically when it is exited with [method SceneTree.quit] or [constant Node.NOTIFICATION_WM_CLOSE_REQUEST]. Command-line [param arguments] can be supplied. To restart the project with the same command line arguments as originally used to run the project, pass [method get_cmdline_args] as the value for [param arguments].
843 This method can be used to apply setting changes that require a restart. See also [method is_restart_on_exit_set] and [method get_restart_on_exit_arguments].
844 [b]Note:[/b] This method is only effective on desktop platforms, and only when the project isn't started from the editor. It will have no effect on mobile and Web platforms, or when the project is started from the editor.
845 [b]Note:[/b] If the project process crashes or is [i]killed[/i] by the user (by sending [code]SIGKILL[/code] instead of the usual [code]SIGTERM[/code]), the project won't restart automatically.
846 </description>
847 </method>
848 <method name="set_thread_name">
849 <return type="int" enum="Error" />
850 <param index="0" name="name" type="String" />
851 <description>
852 Assigns the given name to the current thread. Returns [constant ERR_UNAVAILABLE] if unavailable on the current platform.
853 </description>
854 </method>
855 <method name="set_use_file_access_save_and_swap">
856 <return type="void" />
857 <param index="0" name="enabled" type="bool" />
858 <description>
859 If [param enabled] is [code]true[/code], when opening a file for writing, a temporary file is used in its place. When closed, it is automatically applied to the target file.
860 This can useful when files may be opened by other applications, such as antiviruses, text editors, or even the Godot editor itself.
861 </description>
862 </method>
863 <method name="shell_open">
864 <return type="int" enum="Error" />
865 <param index="0" name="uri" type="String" />
866 <description>
867 Requests the OS to open a resource identified by [param uri] with the most appropriate program. For example:
868 - [code]OS.shell_open("C:\\Users\\name\\Downloads")[/code] on Windows opens the file explorer at the user's Downloads folder.
869 - [code]OS.shell_open("C:/Users/name/Downloads")[/code] also works on Windows and opens the file explorer at the user's Downloads folder.
870 - [code]OS.shell_open("https://godotengine.org")[/code] opens the default web browser on the official Godot website.
871 - [code]OS.shell_open("mailto:[email protected]")[/code] opens the default email client with the "To" field set to [code][email protected][/code]. See [url=https://datatracker.ietf.org/doc/html/rfc2368]RFC 2368 - The [code]mailto[/code] URL scheme[/url] for a list of fields that can be added.
872 Use [method ProjectSettings.globalize_path] to convert a [code]res://[/code] or [code]user://[/code] project path into a system path for use with this method.
873 [b]Note:[/b] Use [method String.uri_encode] to encode characters within URLs in a URL-safe, portable way. This is especially required for line breaks. Otherwise, [method shell_open] may not work correctly in a project exported to the Web platform.
874 [b]Note:[/b] This method is implemented on Android, iOS, Web, Linux, macOS and Windows.
875 </description>
876 </method>
877 <method name="shell_show_in_file_manager">
878 <return type="int" enum="Error" />
879 <param index="0" name="file_or_dir_path" type="String" />
880 <param index="1" name="open_folder" type="bool" default="true" />
881 <description>
882 Requests the OS to open the file manager, navigate to the given [param file_or_dir_path] and select the target file or folder.
883 If [param open_folder] is [code]true[/code] and [param file_or_dir_path] is a valid directory path, the OS will open the file manager and navigate to the target folder without selecting anything.
884 Use [method ProjectSettings.globalize_path] to convert a [code]res://[/code] or [code]user://[/code] project path into a system path to use with this method.
885 [b]Note:[/b] This method is currently only implemented on Windows and macOS. On other platforms, it will fallback to [method shell_open] with a directory path of [param file_or_dir_path] prefixed with [code]file://[/code].
886 </description>
887 </method>
888 <method name="unset_environment" qualifiers="const">
889 <return type="void" />
890 <param index="0" name="variable" type="String" />
891 <description>
892 Removes the given environment variable from the current environment, if it exists. The [param variable] name cannot be empty or include the [code]=[/code] character. The environment variable will be removed for the Godot process and any process executed with [method execute] after running [method unset_environment]. The removal of the environment variable will [i]not[/i] persist to processes run after the Godot process was terminated.
893 [b]Note:[/b] Environment variable names are case-sensitive on all platforms except Windows.
894 </description>
895 </method>
896 </methods>
897 <members>
898 <member name="delta_smoothing" type="bool" setter="set_delta_smoothing" getter="is_delta_smoothing_enabled" default="true">
899 If [code]true[/code], the engine filters the time delta measured between each frame, and attempts to compensate for random variation. This only works on systems where V-Sync is active.
900 [b]Note:[/b] On start-up, this is the same as [member ProjectSettings.application/run/delta_smoothing].
901 </member>
902 <member name="low_processor_usage_mode" type="bool" setter="set_low_processor_usage_mode" getter="is_in_low_processor_usage_mode" default="false">
903 If [code]true[/code], the engine optimizes for low processor usage by only refreshing the screen if needed. Can improve battery consumption on mobile.
904 [b]Note:[/b] On start-up, this is the same as [member ProjectSettings.application/run/low_processor_mode].
905 </member>
906 <member name="low_processor_usage_mode_sleep_usec" type="int" setter="set_low_processor_usage_mode_sleep_usec" getter="get_low_processor_usage_mode_sleep_usec" default="6900">
907 The amount of sleeping between frames when the low-processor usage mode is enabled, in microseconds. Higher values will result in lower CPU usage. See also [member low_processor_usage_mode].
908 [b]Note:[/b] On start-up, this is the same as [member ProjectSettings.application/run/low_processor_mode_sleep_usec].
909 </member>
910 </members>
911 <constants>
912 <constant name="RENDERING_DRIVER_VULKAN" value="0" enum="RenderingDriver">
913 The Vulkan rendering driver. It requires Vulkan 1.0 support and automatically uses features from Vulkan 1.1 and 1.2 if available.
914 </constant>
915 <constant name="RENDERING_DRIVER_OPENGL3" value="1" enum="RenderingDriver">
916 The OpenGL 3 rendering driver. It uses OpenGL 3.3 Core Profile on desktop platforms, OpenGL ES 3.0 on mobile devices, and WebGL 2.0 on Web.
917 </constant>
918 <constant name="RENDERING_DRIVER_D3D12" value="2" enum="RenderingDriver">
919 The Direct3D 12 rendering driver.
920 </constant>
921 <constant name="RENDERING_DRIVER_METAL" value="3" enum="RenderingDriver">
922 The Metal rendering driver.
923 </constant>
924 <constant name="SYSTEM_DIR_DESKTOP" value="0" enum="SystemDir">
925 Refers to the Desktop directory path.
926 </constant>
927 <constant name="SYSTEM_DIR_DCIM" value="1" enum="SystemDir">
928 Refers to the DCIM (Digital Camera Images) directory path.
929 </constant>
930 <constant name="SYSTEM_DIR_DOCUMENTS" value="2" enum="SystemDir">
931 Refers to the Documents directory path.
932 </constant>
933 <constant name="SYSTEM_DIR_DOWNLOADS" value="3" enum="SystemDir">
934 Refers to the Downloads directory path.
935 </constant>
936 <constant name="SYSTEM_DIR_MOVIES" value="4" enum="SystemDir">
937 Refers to the Movies (or Videos) directory path.
938 </constant>
939 <constant name="SYSTEM_DIR_MUSIC" value="5" enum="SystemDir">
940 Refers to the Music directory path.
941 </constant>
942 <constant name="SYSTEM_DIR_PICTURES" value="6" enum="SystemDir">
943 Refers to the Pictures directory path.
944 </constant>
945 <constant name="SYSTEM_DIR_RINGTONES" value="7" enum="SystemDir">
946 Refers to the Ringtones directory path.
947 </constant>
948 <constant name="STD_HANDLE_INVALID" value="0" enum="StdHandleType">
949 Standard I/O device is invalid. No data can be received from or sent to these standard I/O devices.
950 </constant>
951 <constant name="STD_HANDLE_CONSOLE" value="1" enum="StdHandleType">
952 Standard I/O device is a console. This typically occurs when Godot is run from a terminal with no redirection. This is also used for all standard I/O devices when running Godot from the editor, at least on desktop platforms.
953 </constant>
954 <constant name="STD_HANDLE_FILE" value="2" enum="StdHandleType">
955 Standard I/O device is a regular file. This typically occurs with redirection from a terminal, e.g. [code]godot &gt; stdout.txt[/code], [code]godot &lt; stdin.txt[/code] or [code]godot &gt; stdout_stderr.txt 2&gt;&amp;1[/code].
956 </constant>
957 <constant name="STD_HANDLE_PIPE" value="3" enum="StdHandleType">
958 Standard I/O device is a FIFO/pipe. This typically occurs with pipe usage from a terminal, e.g. [code]echo "Hello" | godot[/code].
959 </constant>
960 <constant name="STD_HANDLE_UNKNOWN" value="4" enum="StdHandleType">
961 Standard I/O device type is unknown.
962 </constant>
963 </constants>
964 </class>