OS.get_processor_count()
thiendepzai1092006 / CODE OS
CODE OS
A comprehensive cheat sheet for the Godot Engine's OS class, covering processes, memory, environment, display, input, and system interaction.
Processes & Memory
Processes & Threads
|
Returns the number of CPU cores available. Example:
|
|
Returns the name of the CPU. Example:
|
|
Checks if a process with the given Example:
|
|
Returns the ID of the current process. Example:
|
|
Kills the process with the specified Example:
|
|
Returns the ID of the main thread. Example:
|
|
Returns the ID of the current thread. Example:
|
|
Checks if multi-threading is supported. Example:
|
|
Sets the name of the current thread. Example:
|
Memory Usage
|
Returns the amount of dynamic memory used (for debugging). Example:
|
|
Returns the peak static memory usage (for debugging). Example:
|
|
Returns the current static memory usage (for debugging). Example:
|
Resource Debugging
|
Prints all resources to the specified file path. Example:
|
|
Prints all textures sorted by size. Example:
|
|
Prints resources of the specified types. Example:
|
|
Prints the resources that are currently in use. Example:
|
Environment & System
Directories
|
Returns the global cache directory. Example:
|
|
Returns the user configuration directory. Example:
|
|
Returns the global data directory. Example:
|
|
Returns the user data directory. Example:
|
|
Returns a system directory based on the Example:
|
Environment Variables
|
Returns the path to the executable file. Example:
|
|
Checks if an environment variable exists. Example:
|
|
Returns the value of an environment variable. Example:
|
|
Sets an environment variable. Example:
|
System Interaction
|
Checks if the Example:
|
|
Dumps memory information to a file (debugging). Example:
|
|
Dumps resource information to a file. Example:
|
|
Moves a file to the system trash. Example:
|
Display & Input
Display Settings
|
Checks if the engine can draw to the screen. Example:
|
|
Returns the screen position. Example:
|
|
Returns the screen size. Example:
|
|
Returns the screen DPI. Example:
|
|
Returns the screen refresh rate. Example:
|
|
Returns the maximum screen scale. Example:
|
|
Returns the current screen scale. Example:
|
|
Sets or gets the current screen index. Example:
|
|
Returns the number of screens. Example:
|
Input Management
|
Returns the number of keyboard layouts. Example:
|
|
Returns the name of a keyboard layout by index. Example:
|
|
Returns the index of the current keyboard layout. Example:
|
|
Returns the language of a keyboard layout by index. Example:
|
|
Sets the current keyboard layout. Example:
|
|
Returns the string representation of a scancode. Example:
|
Virtual Keyboard & Touchscreen
|
Checks if a touchscreen is available. Example:
|
|
Checks if a virtual keyboard is available. Example:
|
|
Shows the virtual keyboard. Example:
|
|
Hides the virtual keyboard. Example:
|
|
Returns the height of the virtual keyboard. Example:
|
System Information
OS Information
|
Returns the name of the operating system. Example:
|
|
Returns the system locale. Example:
|
|
Returns the system language code. Example:
|
|
Returns the device model name. Example:
|
|
Returns a unique device ID. Example:
|
System Features & Build Info
|
Checks if the engine has a specific feature. Example:
|
|
Checks if the engine is running in verbose mode. Example:
|
|
Checks if the engine is a debug build. Example:
|
System Interaction
|
Requests the window’s attention. Example:
|
|
Crashes the engine (for testing purposes only). Example:
|
|
Displays an alert dialog. Example:
|
|
Opens a URI in the default browser. Example:
|
|
Delays execution for a specified number of milliseconds. Example:
|
|
Gets or sets the system clipboard content. Example:
|
Multimedia & Platform Features
Sound & Text-to-Speech
|
Returns a list of available TTS voices. Example:
|
|
Returns TTS voices for a specific language. Example:
|
|
Speaks the given text using the specified voice. Example:
|
|
Stops the current TTS utterance. Example:
|
|
Pauses the current TTS utterance. Example:
|
|
Resumes a paused TTS utterance. Example:
|
Native Video Playback
|
Plays a native video file. Example:
|
|
Stops the currently playing native video. Example:
|
|
Pauses the currently playing native video. Example:
|
|
Unpauses the currently playing native video. Example:
|
|
Checks if a native video is currently playing. Example:
|
Android Permissions
|
Requests a specific Android permission. Example:
|
|
Requests all required Android permissions. Example:
|
|
Returns a list of granted Android permissions. Example:
|
|
Keeps the screen on (for mobile devices). Example:
|