Documentation
¶
Overview ¶
The graphics.gd/classdb/Engine singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others. It also stores information about the current build of Godot, such as the current version.
Index ¶
- func Advanced() class
- func GetArchitectureName() string
- func GetFramesDrawn() int
- func GetFramesPerSecond() Float.X
- func GetLicenseInfo() map[string]string
- func GetLicenseText() string
- func GetMainLoop() MainLoop.Instance
- func GetPhysicsFrames() int
- func GetPhysicsInterpolationFraction() Float.X
- func GetProcessFrames() int
- func GetScriptLanguage(index int) ScriptLanguage.Instance
- func GetScriptLanguageCount() int
- func GetSingleton(name string) Object.Instance
- func GetSingletonList() []string
- func GetWriteMoviePath() string
- func HasSingleton(name string) bool
- func IsEditorHint() bool
- func IsEmbeddedInEditor() bool
- func IsInPhysicsFrame() bool
- func Log(v ...any)
- func Logv(v ...any)
- func MaxFps() int
- func MaxPhysicsStepsPerFrame() int
- func PhysicsJitterFix() Float.X
- func PhysicsTicksPerSecond() int
- func Print(v ...any)
- func PrintErrorMessages() bool
- func PrintRich(v ...any)
- func PrintToStdout() bool
- func Println(v ...any)
- func Raise(err error)
- func RaiseWarning(v ...any)
- func RegisterScriptLanguage(language ScriptLanguage.Instance) error
- func RegisterSingleton(name string, instance Object.Instance)
- func SetMaxFps(value int)
- func SetMaxPhysicsStepsPerFrame(value int)
- func SetPhysicsJitterFix(value Float.X)
- func SetPhysicsTicksPerSecond(value int)
- func SetPrintErrorMessages(value bool)
- func SetPrintToStdout(value bool)
- func SetTimeScale(value Float.X)
- func TimeScale() Float.X
- func UnregisterScriptLanguage(language ScriptLanguage.Instance) error
- func UnregisterSingleton(name string)
- func Version() string
- type AuthorInfo
- type Copyright
- type DonorInfo
- type Extension
- type ID
- type Instance
- type Part
- type VersionInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Advanced ¶
func Advanced() class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
func GetArchitectureName ¶
func GetArchitectureName() string
Returns the name of the CPU architecture the Godot binary was built for. Possible return values include "x86_64", "x86_32", "arm64", "arm32", "rv64", "riscv", "ppc64", "ppc", "wasm64", and "wasm32".
To detect whether the current build is 64-bit, or the type of architecture, don't use the architecture name. Instead, use graphics.gd/classdb/OS.HasFeature to check for the "64" feature tag, or tags such as "x86" or "arm". See the Feature Tags documentation for more details.
Note: This method does not return the name of the system's CPU architecture (like graphics.gd/classdb/OS.GetProcessorName). For example, when running an x86_32 Godot binary on an x86_64 system, the returned value will still be "x86_32".
func GetFramesDrawn ¶
func GetFramesDrawn() int
Returns the total number of frames drawn since the engine started.
Note: On headless platforms, or if rendering is disabled with --disable-render-loop via command line, this method always returns 0. See also GetProcessFrames.
func GetFramesPerSecond ¶
Returns the average frames rendered every second (FPS), also known as the framerate.
func GetLicenseInfo ¶
Returns a data structure of licenses used by Godot and included third party components. Each entry is a license name (such as "Expat") and its associated text.
func GetMainLoop ¶
Returns the instance of the graphics.gd/classdb/MainLoop. This is usually the main graphics.gd/classdb/SceneTree and is the same as graphics.gd/classdb/Node.Instance.GetTree.
Note: The type instantiated as the main loop can changed with graphics.gd/classdb/ProjectSettings "application/run/main_loop_type".
func GetPhysicsFrames ¶
func GetPhysicsFrames() int
Returns the total number of frames passed since the engine started. This number is increased every physics frame. See also GetProcessFrames.
This method can be used to run expensive logic less often without relying on a graphics.gd/classdb/Timer:
func GetPhysicsInterpolationFraction ¶
Returns the fraction through the current physics tick we are at the time of rendering the frame. This can be used to implement fixed timestep interpolation.
func GetProcessFrames ¶
func GetProcessFrames() int
Returns the total number of frames passed since the engine started. This number is increased every process frame, regardless of whether the render loop is enabled. See also GetFramesDrawn and GetPhysicsFrames.
This method can be used to run expensive logic less often without relying on a graphics.gd/classdb/Timer:
func GetScriptLanguage ¶
func GetScriptLanguage(index int) ScriptLanguage.Instance
Returns an instance of a graphics.gd/classdb/ScriptLanguage with the given 'index'.
func GetScriptLanguageCount ¶
func GetScriptLanguageCount() int
Returns the number of available script languages. Use with GetScriptLanguage.
func GetSingleton ¶
Returns the global singleton with the given 'name', or null if it does not exist. Often used for plugins. See also HasSingleton and GetSingletonList.
Note: Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
func GetSingletonList ¶
func GetSingletonList() []string
Returns a list of names of all available global singletons. See also GetSingleton.
func GetWriteMoviePath ¶
func GetWriteMoviePath() string
Returns the path to the graphics.gd/classdb/MovieWriter's output file, or an empty string if the engine wasn't started in Movie Maker mode. The default path can be changed in graphics.gd/classdb/ProjectSettings "editor/movie_writer/movie_file".
func HasSingleton ¶
Returns true if a singleton with the given 'name' exists in the global scope. See also GetSingleton.
Note: Global singletons are not the same as autoloaded nodes, which are configurable in the project settings.
func IsEditorHint ¶
func IsEditorHint() bool
Returns true if the script is currently running inside the editor, otherwise returns false. This is useful for @tool scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor:
See Running code in the editor in the documentation for more information.
Note: To detect whether the script is running on an editor build (such as when pressing F5), use graphics.gd/classdb/OS.HasFeature with the "editor" argument instead. OS.has_feature("editor") evaluate to true both when the script is running in the editor and when running the project from the editor, but returns false when run from an exported project.
func IsEmbeddedInEditor ¶
func IsEmbeddedInEditor() bool
Returns true if the engine is running embedded in the editor. This is useful to prevent attempting to update window mode or window flags that are not supported when running the project embedded in the editor.
func IsInPhysicsFrame ¶
func IsInPhysicsFrame() bool
Returns true if the engine is inside the fixed physics process step of the main loop.
func Log ¶
func Log(v ...any)
Log prints one or more arguments to strings in the best way possible to standard error line
func Logv ¶
func Logv(v ...any)
Logv prints if verbose mode is enabled (OS.is_stdout_verbose returning true), converts one or more arguments of any type to string in the best way possible and prints them to the console.
func MaxPhysicsStepsPerFrame ¶
func MaxPhysicsStepsPerFrame() int
func PhysicsJitterFix ¶
func PhysicsTicksPerSecond ¶
func PhysicsTicksPerSecond() int
func Print ¶
func Print(v ...any)
Print prints one or more arguments to strings in the best way possible to the OS terminal. Unlike print, no newline is automatically added at the end.
func PrintErrorMessages ¶
func PrintErrorMessages() bool
func PrintRich ¶
func PrintRich(v ...any)
PrintRich converts one or more arguments of any type to string in the best way possible and prints them to the console.
The following BBCode tags are supported: b, i, u, s, indent, code, url, center, right, color, bgcolor, fgcolor.
Color tags only support the following named colors: black, red, green, yellow, blue, magenta, pink, purple, cyan, white, orange, gray. Hexadecimal color codes are not supported.
URL tags only support URLs wrapped by a URL tag, not URLs with a different title.
When printing to standard output, the supported subset of BBCode is converted to ANSI escape codes for the terminal emulator to display. Support for ANSI escape codes varies across terminal emulators, especially for italic and strikethrough. In standard output, code is represented with faint text but without any font change. Unsupported tags are left as-is in standard output.
func PrintToStdout ¶
func PrintToStdout() bool
func Println ¶
func Println(v ...any)
Println converts one or more arguments of any type to string in the best way possible and prints them to the console.
func Raise ¶
func Raise(err error)
Raise pushes an error message to Godot's built-in debugger and to the OS terminal.
func RaiseWarning ¶
func RaiseWarning(v ...any)
RaiseWarning pushes a warning message to Godot's built-in debugger and to the OS terminal.
func RegisterScriptLanguage ¶
func RegisterScriptLanguage(language ScriptLanguage.Instance) error
Registers a graphics.gd/classdb/ScriptLanguage instance to be available with ScriptServer.
Returns:
- [Ok] on success;
- [ErrUnavailable] if ScriptServer has reached the limit and cannot register any new language;
- [ErrAlreadyExists] if ScriptServer already contains a language with similar extension/name/type.
func RegisterSingleton ¶
Registers the given graphics.gd/classdb/Object 'instance' as a singleton, available globally under 'name'. Useful for plugins.
func SetMaxPhysicsStepsPerFrame ¶
func SetMaxPhysicsStepsPerFrame(value int)
func SetPhysicsJitterFix ¶
func SetPhysicsTicksPerSecond ¶
func SetPhysicsTicksPerSecond(value int)
func SetPrintErrorMessages ¶
func SetPrintErrorMessages(value bool)
func SetPrintToStdout ¶
func SetPrintToStdout(value bool)
func SetTimeScale ¶
func UnregisterScriptLanguage ¶
func UnregisterScriptLanguage(language ScriptLanguage.Instance) error
Unregisters the graphics.gd/classdb/ScriptLanguage instance from ScriptServer.
Returns:
- [Ok] on success;
- [ErrDoesNotExist] if the language is not registered in ScriptServer.
func UnregisterSingleton ¶
func UnregisterSingleton(name string)
Removes the singleton registered under 'name'. The singleton object is not freed. Only works with user-defined singletons registered with RegisterSingleton.
Types ¶
type AuthorInfo ¶
type AuthorInfo struct { LeadDevelopers []string `gd:"lead_developers"` Founders []string `gd:"founders"` ProjectManagers []string `gd:"project_managers"` Developers []string `gd:"developers"` }
func GetAuthorInfo ¶
func GetAuthorInfo() AuthorInfo
Returns the engine author information as a data structure, where each entry is an slice of strings with the names of notable contributors to the Godot Engine: lead_developers, founders, project_managers, and developers.
type Copyright ¶
func GetCopyrightInfo ¶
func GetCopyrightInfo() []Copyright
Returns an slice of dictionaries with copyright information for every component of Godot's source code.
Every data structure contains a name identifier, and a parts array of dictionaries. It describes the component in detail with the following entries:
- files - slice of file paths from the source code affected by this component;
- copyright - slice of owners of this component;
- license - The license applied to this component (such as "Expat" or "CC-BY-4.0").
type DonorInfo ¶
type DonorInfo struct { PlatinumSponsors []string `gd:"platinum_sponsors"` GoldSponsors []string `gd:"gold_sponsors"` SilverSponsors []string `gd:"silver_sponsors"` BronzeSponsors []string `gd:"bronze_sponsors"` MiniSponsors []string `gd:"mini_sponsors"` GoldDonors []string `gd:"gold_donors"` SilverDonors []string `gd:"silver_donors"` BronzeDonors []string `gd:"bronze_donors"` }
func GetDonorInfo ¶
func GetDonorInfo() DonorInfo
Returns a data structure of categorized donor names. Each entry is an slice of strings:
{platinum_sponsors, gold_sponsors, silver_sponsors, bronze_sponsors, mini_sponsors, gold_donors, silver_donors, bronze_donors}
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type VersionInfo ¶
type VersionInfo struct { Major int `gd:"major"` Minor int `gd:"minor"` Patch int `gd:"patch"` Hex int `gd:"hex"` Status string `gd:"status"` Build string `gd:"build"` Hash string `gd:"hash"` Timestamp int `gd:"timestamp"` String string `gd:"string"` }
func GetVersionInfo ¶
func GetVersionInfo() VersionInfo
Returns the current engine version information as a data structure containing the following entries:
- major - Major version number as an int;
- minor - Minor version number as an int;
- patch - Patch version number as an int;
- hex - Full version encoded as a hexadecimal int with one byte (2 hex digits) per number (see example below);
- status - Status (such as "beta", "rc1", "rc2", "stable", etc.) as a String;
- build - Build name (e.g. "custom_build") as a String;
- hash - Full Git commit hash as a String;
- timestamp - Holds the Git commit date UNIX timestamp in seconds as an int, or 0 if unavailable;
- string - major, minor, patch, status, and build in a single String.
The hex value is encoded as follows, from left to right: one byte for the major, one byte for the minor, one byte for the patch version. For example, "3.1.12" would be 0x03010C.
Note: The hex value is still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for quick version comparisons from code: