class_engine.rst 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/Engine.xml.
  6. .. _class_Engine:
  7. Engine
  8. ======
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Access to engine properties.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. The **Engine** singleton allows you to query and modify the project's run-time parameters, such as frames per second, time scale, and others.
  15. .. rst-class:: classref-reftable-group
  16. Properties
  17. ----------
  18. .. table::
  19. :widths: auto
  20. +---------------------------+---------------------------------------------------------------------------------------+----------+
  21. | :ref:`int<class_int>` | :ref:`max_fps<class_Engine_property_max_fps>` | ``0`` |
  22. +---------------------------+---------------------------------------------------------------------------------------+----------+
  23. | :ref:`int<class_int>` | :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` | ``8`` |
  24. +---------------------------+---------------------------------------------------------------------------------------+----------+
  25. | :ref:`float<class_float>` | :ref:`physics_jitter_fix<class_Engine_property_physics_jitter_fix>` | ``0.5`` |
  26. +---------------------------+---------------------------------------------------------------------------------------+----------+
  27. | :ref:`int<class_int>` | :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` | ``60`` |
  28. +---------------------------+---------------------------------------------------------------------------------------+----------+
  29. | :ref:`bool<class_bool>` | :ref:`print_error_messages<class_Engine_property_print_error_messages>` | ``true`` |
  30. +---------------------------+---------------------------------------------------------------------------------------+----------+
  31. | :ref:`float<class_float>` | :ref:`time_scale<class_Engine_property_time_scale>` | ``1.0`` |
  32. +---------------------------+---------------------------------------------------------------------------------------+----------+
  33. .. rst-class:: classref-reftable-group
  34. Methods
  35. -------
  36. .. table::
  37. :widths: auto
  38. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`String<class_String>` | :ref:`get_architecture_name<class_Engine_method_get_architecture_name>` **(** **)** |const| |
  40. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_author_info<class_Engine_method_get_author_info>` **(** **)** |const| |
  42. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`Dictionary[]<class_Dictionary>` | :ref:`get_copyright_info<class_Engine_method_get_copyright_info>` **(** **)** |const| |
  44. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_donor_info<class_Engine_method_get_donor_info>` **(** **)** |const| |
  46. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`int<class_int>` | :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>` **(** **)** |
  48. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`get_frames_per_second<class_Engine_method_get_frames_per_second>` **(** **)** |const| |
  50. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_license_info<class_Engine_method_get_license_info>` **(** **)** |const| |
  52. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`String<class_String>` | :ref:`get_license_text<class_Engine_method_get_license_text>` **(** **)** |const| |
  54. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`MainLoop<class_MainLoop>` | :ref:`get_main_loop<class_Engine_method_get_main_loop>` **(** **)** |const| |
  56. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_physics_frames<class_Engine_method_get_physics_frames>` **(** **)** |const| |
  58. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`float<class_float>` | :ref:`get_physics_interpolation_fraction<class_Engine_method_get_physics_interpolation_fraction>` **(** **)** |const| |
  60. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`get_process_frames<class_Engine_method_get_process_frames>` **(** **)** |const| |
  62. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`ScriptLanguage<class_ScriptLanguage>` | :ref:`get_script_language<class_Engine_method_get_script_language>` **(** :ref:`int<class_int>` index **)** |const| |
  64. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`get_script_language_count<class_Engine_method_get_script_language_count>` **(** **)** |
  66. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Object<class_Object>` | :ref:`get_singleton<class_Engine_method_get_singleton>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  68. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`get_singleton_list<class_Engine_method_get_singleton_list>` **(** **)** |const| |
  70. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_version_info<class_Engine_method_get_version_info>` **(** **)** |const| |
  72. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`String<class_String>` | :ref:`get_write_movie_path<class_Engine_method_get_write_movie_path>` **(** **)** |const| |
  74. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`has_singleton<class_Engine_method_has_singleton>` **(** :ref:`StringName<class_StringName>` name **)** |const| |
  76. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`bool<class_bool>` | :ref:`is_editor_hint<class_Engine_method_is_editor_hint>` **(** **)** |const| |
  78. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | :ref:`bool<class_bool>` | :ref:`is_in_physics_frame<class_Engine_method_is_in_physics_frame>` **(** **)** |const| |
  80. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`register_script_language<class_Engine_method_register_script_language>` **(** :ref:`ScriptLanguage<class_ScriptLanguage>` language **)** |
  82. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`register_singleton<class_Engine_method_register_singleton>` **(** :ref:`StringName<class_StringName>` name, :ref:`Object<class_Object>` instance **)** |
  84. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`unregister_singleton<class_Engine_method_unregister_singleton>` **(** :ref:`StringName<class_StringName>` name **)** |
  86. +---------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. .. rst-class:: classref-section-separator
  88. ----
  89. .. rst-class:: classref-descriptions-group
  90. Property Descriptions
  91. ---------------------
  92. .. _class_Engine_property_max_fps:
  93. .. rst-class:: classref-property
  94. :ref:`int<class_int>` **max_fps** = ``0``
  95. .. rst-class:: classref-property-setget
  96. - void **set_max_fps** **(** :ref:`int<class_int>` value **)**
  97. - :ref:`int<class_int>` **get_max_fps** **(** **)**
  98. The maximum number of frames per second that can be rendered. A value of ``0`` means "no limit". The actual number of frames per second may still be below this value if the CPU or GPU cannot keep up with the project logic and rendering.
  99. Limiting the FPS can be useful to reduce system power consumption, which reduces heat and noise emissions (and improves battery life on mobile devices).
  100. If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_display/window/vsync/vsync_mode>` is ``Enabled`` or ``Adaptive``, it takes precedence and the forced FPS number cannot exceed the monitor's refresh rate.
  101. If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_display/window/vsync/vsync_mode>` is ``Enabled``, on monitors with variable refresh rate enabled (G-Sync/FreeSync), using a FPS limit a few frames lower than the monitor's refresh rate will `reduce input lag while avoiding tearing <https://blurbusters.com/howto-low-lag-vsync-on/>`__.
  102. If :ref:`ProjectSettings.display/window/vsync/vsync_mode<class_ProjectSettings_property_display/window/vsync/vsync_mode>` is ``Disabled``, limiting the FPS to a high value that can be consistently reached on the system can reduce input lag compared to an uncapped framerate. Since this works by ensuring the GPU load is lower than 100%, this latency reduction is only effective in GPU-bottlenecked scenarios, not CPU-bottlenecked scenarios.
  103. See also :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` and :ref:`ProjectSettings.application/run/max_fps<class_ProjectSettings_property_application/run/max_fps>`.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_Engine_property_max_physics_steps_per_frame:
  107. .. rst-class:: classref-property
  108. :ref:`int<class_int>` **max_physics_steps_per_frame** = ``8``
  109. .. rst-class:: classref-property-setget
  110. - void **set_max_physics_steps_per_frame** **(** :ref:`int<class_int>` value **)**
  111. - :ref:`int<class_int>` **get_max_physics_steps_per_frame** **(** **)**
  112. Controls the maximum number of physics steps that can be simulated each rendered frame. The default value is tuned to avoid "spiral of death" situations where expensive physics simulations trigger more expensive simulations indefinitely. However, the game will appear to slow down if the rendering FPS is less than ``1 / max_physics_steps_per_frame`` of :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>`. This occurs even if ``delta`` is consistently used in physics calculations. To avoid this, increase :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` if you have increased :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` significantly above its default value.
  113. .. rst-class:: classref-item-separator
  114. ----
  115. .. _class_Engine_property_physics_jitter_fix:
  116. .. rst-class:: classref-property
  117. :ref:`float<class_float>` **physics_jitter_fix** = ``0.5``
  118. .. rst-class:: classref-property-setget
  119. - void **set_physics_jitter_fix** **(** :ref:`float<class_float>` value **)**
  120. - :ref:`float<class_float>` **get_physics_jitter_fix** **(** **)**
  121. Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of the in-game clock and real clock but smooth out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended.
  122. \ **Note:** For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting :ref:`physics_jitter_fix<class_Engine_property_physics_jitter_fix>` to ``0``.
  123. .. rst-class:: classref-item-separator
  124. ----
  125. .. _class_Engine_property_physics_ticks_per_second:
  126. .. rst-class:: classref-property
  127. :ref:`int<class_int>` **physics_ticks_per_second** = ``60``
  128. .. rst-class:: classref-property-setget
  129. - void **set_physics_ticks_per_second** **(** :ref:`int<class_int>` value **)**
  130. - :ref:`int<class_int>` **get_physics_ticks_per_second** **(** **)**
  131. The number of fixed iterations per second. This controls how often physics simulation and :ref:`Node._physics_process<class_Node_method__physics_process>` methods are run. This value should generally always be set to ``60`` or above, as Godot doesn't interpolate the physics step. As a result, values lower than ``60`` will look stuttery. This value can be increased to make input more reactive or work around collision tunneling issues, but keep in mind doing so will increase CPU usage. See also :ref:`max_fps<class_Engine_property_max_fps>` and :ref:`ProjectSettings.physics/common/physics_ticks_per_second<class_ProjectSettings_property_physics/common/physics_ticks_per_second>`.
  132. \ **Note:** Only :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` physics ticks may be simulated per rendered frame at most. If more physics ticks have to be simulated per rendered frame to keep up with rendering, the project will appear to slow down (even if ``delta`` is used consistently in physics calculations). Therefore, it is recommended to also increase :ref:`max_physics_steps_per_frame<class_Engine_property_max_physics_steps_per_frame>` if increasing :ref:`physics_ticks_per_second<class_Engine_property_physics_ticks_per_second>` significantly above its default value.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_Engine_property_print_error_messages:
  136. .. rst-class:: classref-property
  137. :ref:`bool<class_bool>` **print_error_messages** = ``true``
  138. .. rst-class:: classref-property-setget
  139. - void **set_print_error_messages** **(** :ref:`bool<class_bool>` value **)**
  140. - :ref:`bool<class_bool>` **is_printing_error_messages** **(** **)**
  141. If ``false``, stops printing error and warning messages to the console and editor Output log. This can be used to hide error and warning messages during unit test suite runs. This property is equivalent to the :ref:`ProjectSettings.application/run/disable_stderr<class_ProjectSettings_property_application/run/disable_stderr>` project setting.
  142. \ **Warning:** If you set this to ``false`` anywhere in the project, important error messages may be hidden even if they are emitted from other scripts. If this is set to ``false`` in a ``@tool`` script, this will also impact the editor itself. Do *not* report bugs before ensuring error messages are enabled (as they are by default).
  143. \ **Note:** This property does not impact the editor's Errors tab when running a project from the editor.
  144. .. rst-class:: classref-item-separator
  145. ----
  146. .. _class_Engine_property_time_scale:
  147. .. rst-class:: classref-property
  148. :ref:`float<class_float>` **time_scale** = ``1.0``
  149. .. rst-class:: classref-property-setget
  150. - void **set_time_scale** **(** :ref:`float<class_float>` value **)**
  151. - :ref:`float<class_float>` **get_time_scale** **(** **)**
  152. Controls how fast or slow the in-game clock ticks versus the real life one. It defaults to 1.0. A value of 2.0 means the game moves twice as fast as real life, whilst a value of 0.5 means the game moves at half the regular speed.
  153. .. rst-class:: classref-section-separator
  154. ----
  155. .. rst-class:: classref-descriptions-group
  156. Method Descriptions
  157. -------------------
  158. .. _class_Engine_method_get_architecture_name:
  159. .. rst-class:: classref-method
  160. :ref:`String<class_String>` **get_architecture_name** **(** **)** |const|
  161. Returns the name of the CPU architecture the Godot binary was built for. Possible return values are ``x86_64``, ``x86_32``, ``arm64``, ``armv7``, ``rv64``, ``riscv``, ``ppc64``, ``ppc``, ``wasm64`` and ``wasm32``.
  162. To detect whether the current CPU architecture is 64-bit, you can use the fact that all 64-bit architecture names have ``64`` in their name:
  163. .. tabs::
  164. .. code-tab:: gdscript
  165. if "64" in Engine.get_architecture_name():
  166. print("Running on 64-bit CPU.")
  167. else:
  168. print("Running on 32-bit CPU.")
  169. .. code-tab:: csharp
  170. if (Engine.GetArchitectureName().Contains("64"))
  171. GD.Print("Running on 64-bit CPU.");
  172. else
  173. GD.Print("Running on 32-bit CPU.");
  174. \ **Note:** :ref:`get_architecture_name<class_Engine_method_get_architecture_name>` does *not* return the name of the host CPU architecture. For example, if running an x86_32 Godot binary on a x86_64 system, the returned value will be ``x86_32``.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_Engine_method_get_author_info:
  178. .. rst-class:: classref-method
  179. :ref:`Dictionary<class_Dictionary>` **get_author_info** **(** **)** |const|
  180. Returns engine author information in a Dictionary.
  181. \ ``lead_developers`` - Array of Strings, lead developer names
  182. \ ``founders`` - Array of Strings, founder names
  183. \ ``project_managers`` - Array of Strings, project manager names
  184. \ ``developers`` - Array of Strings, developer names
  185. .. rst-class:: classref-item-separator
  186. ----
  187. .. _class_Engine_method_get_copyright_info:
  188. .. rst-class:: classref-method
  189. :ref:`Dictionary[]<class_Dictionary>` **get_copyright_info** **(** **)** |const|
  190. Returns an Array of copyright information Dictionaries.
  191. \ ``name`` - String, component name
  192. \ ``parts`` - Array of Dictionaries {``files``, ``copyright``, ``license``} describing subsections of the component
  193. .. rst-class:: classref-item-separator
  194. ----
  195. .. _class_Engine_method_get_donor_info:
  196. .. rst-class:: classref-method
  197. :ref:`Dictionary<class_Dictionary>` **get_donor_info** **(** **)** |const|
  198. Returns a Dictionary of Arrays of donor names.
  199. {``platinum_sponsors``, ``gold_sponsors``, ``silver_sponsors``, ``bronze_sponsors``, ``mini_sponsors``, ``gold_donors``, ``silver_donors``, ``bronze_donors``}
  200. .. rst-class:: classref-item-separator
  201. ----
  202. .. _class_Engine_method_get_frames_drawn:
  203. .. rst-class:: classref-method
  204. :ref:`int<class_int>` **get_frames_drawn** **(** **)**
  205. Returns the total number of frames drawn. On headless platforms, or if the render loop is disabled with ``--disable-render-loop`` via command line, :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>` always returns ``0``. See :ref:`get_process_frames<class_Engine_method_get_process_frames>`.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_Engine_method_get_frames_per_second:
  209. .. rst-class:: classref-method
  210. :ref:`float<class_float>` **get_frames_per_second** **(** **)** |const|
  211. Returns the frames per second of the running game.
  212. .. rst-class:: classref-item-separator
  213. ----
  214. .. _class_Engine_method_get_license_info:
  215. .. rst-class:: classref-method
  216. :ref:`Dictionary<class_Dictionary>` **get_license_info** **(** **)** |const|
  217. Returns Dictionary of licenses used by Godot and included third party components.
  218. .. rst-class:: classref-item-separator
  219. ----
  220. .. _class_Engine_method_get_license_text:
  221. .. rst-class:: classref-method
  222. :ref:`String<class_String>` **get_license_text** **(** **)** |const|
  223. Returns Godot license text.
  224. .. rst-class:: classref-item-separator
  225. ----
  226. .. _class_Engine_method_get_main_loop:
  227. .. rst-class:: classref-method
  228. :ref:`MainLoop<class_MainLoop>` **get_main_loop** **(** **)** |const|
  229. Returns the main loop object (see :ref:`MainLoop<class_MainLoop>` and :ref:`SceneTree<class_SceneTree>`).
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_Engine_method_get_physics_frames:
  233. .. rst-class:: classref-method
  234. :ref:`int<class_int>` **get_physics_frames** **(** **)** |const|
  235. Returns the total number of frames passed since engine initialization which is advanced on each **physics frame**. See also :ref:`get_process_frames<class_Engine_method_get_process_frames>`.
  236. \ :ref:`get_physics_frames<class_Engine_method_get_physics_frames>` can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
  237. .. tabs::
  238. .. code-tab:: gdscript
  239. func _physics_process(_delta):
  240. if Engine.get_physics_frames() % 2 == 0:
  241. pass # Run expensive logic only once every 2 physics frames here.
  242. .. code-tab:: csharp
  243. public override void _PhysicsProcess(double delta)
  244. {
  245. base._PhysicsProcess(delta);
  246. if (Engine.GetPhysicsFrames() % 2 == 0)
  247. {
  248. // Run expensive logic only once every 2 physics frames here.
  249. }
  250. }
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_Engine_method_get_physics_interpolation_fraction:
  254. .. rst-class:: classref-method
  255. :ref:`float<class_float>` **get_physics_interpolation_fraction** **(** **)** |const|
  256. 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.
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_Engine_method_get_process_frames:
  260. .. rst-class:: classref-method
  261. :ref:`int<class_int>` **get_process_frames** **(** **)** |const|
  262. Returns the total number of frames passed since engine initialization which is advanced on each **process frame**, regardless of whether the render loop is enabled. See also :ref:`get_frames_drawn<class_Engine_method_get_frames_drawn>` and :ref:`get_physics_frames<class_Engine_method_get_physics_frames>`.
  263. \ :ref:`get_process_frames<class_Engine_method_get_process_frames>` can be used to run expensive logic less often without relying on a :ref:`Timer<class_Timer>`:
  264. .. tabs::
  265. .. code-tab:: gdscript
  266. func _process(_delta):
  267. if Engine.get_process_frames() % 2 == 0:
  268. pass # Run expensive logic only once every 2 process (render) frames here.
  269. .. code-tab:: csharp
  270. public override void _Process(double delta)
  271. {
  272. base._Process(delta);
  273. if (Engine.GetProcessFrames() % 2 == 0)
  274. {
  275. // Run expensive logic only once every 2 physics frames here.
  276. }
  277. }
  278. .. rst-class:: classref-item-separator
  279. ----
  280. .. _class_Engine_method_get_script_language:
  281. .. rst-class:: classref-method
  282. :ref:`ScriptLanguage<class_ScriptLanguage>` **get_script_language** **(** :ref:`int<class_int>` index **)** |const|
  283. Returns an instance of a :ref:`ScriptLanguage<class_ScriptLanguage>` with the given index.
  284. .. rst-class:: classref-item-separator
  285. ----
  286. .. _class_Engine_method_get_script_language_count:
  287. .. rst-class:: classref-method
  288. :ref:`int<class_int>` **get_script_language_count** **(** **)**
  289. Returns the number of available script languages. Use with :ref:`get_script_language<class_Engine_method_get_script_language>`.
  290. .. rst-class:: classref-item-separator
  291. ----
  292. .. _class_Engine_method_get_singleton:
  293. .. rst-class:: classref-method
  294. :ref:`Object<class_Object>` **get_singleton** **(** :ref:`StringName<class_StringName>` name **)** |const|
  295. Returns a global singleton with given ``name``. Often used for plugins, e.g. GodotPayments.
  296. .. rst-class:: classref-item-separator
  297. ----
  298. .. _class_Engine_method_get_singleton_list:
  299. .. rst-class:: classref-method
  300. :ref:`PackedStringArray<class_PackedStringArray>` **get_singleton_list** **(** **)** |const|
  301. Returns a list of available global singletons.
  302. .. rst-class:: classref-item-separator
  303. ----
  304. .. _class_Engine_method_get_version_info:
  305. .. rst-class:: classref-method
  306. :ref:`Dictionary<class_Dictionary>` **get_version_info** **(** **)** |const|
  307. Returns the current engine version information in a Dictionary.
  308. \ ``major`` - Holds the major version number as an int
  309. \ ``minor`` - Holds the minor version number as an int
  310. \ ``patch`` - Holds the patch version number as an int
  311. \ ``hex`` - Holds the full version number encoded as a hexadecimal int with one byte (2 places) per number (see example below)
  312. \ ``status`` - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String
  313. \ ``build`` - Holds the build name (e.g. "custom_build") as a String
  314. \ ``hash`` - Holds the full Git commit hash as a String
  315. \ ``year`` - Holds the year the version was released in as an int
  316. \ ``string`` - ``major`` + ``minor`` + ``patch`` + ``status`` + ``build`` in a single String
  317. 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:** It's still an int internally, and printing it will give you its decimal representation, which is not particularly meaningful. Use hexadecimal literals for easy version comparisons from code:
  318. .. tabs::
  319. .. code-tab:: gdscript
  320. if Engine.get_version_info().hex >= 0x030200:
  321. # Do things specific to version 3.2 or later
  322. else:
  323. # Do things specific to versions before 3.2
  324. .. code-tab:: csharp
  325. if ((int)Engine.GetVersionInfo()["hex"] >= 0x030200)
  326. {
  327. // Do things specific to version 3.2 or later
  328. }
  329. else
  330. {
  331. // Do things specific to versions before 3.2
  332. }
  333. .. rst-class:: classref-item-separator
  334. ----
  335. .. _class_Engine_method_get_write_movie_path:
  336. .. rst-class:: classref-method
  337. :ref:`String<class_String>` **get_write_movie_path** **(** **)** |const|
  338. Returns the path to the :ref:`MovieWriter<class_MovieWriter>`'s output file, or an empty string if the engine wasn't started in Movie Maker mode. This path can be absolute or relative depending on how the user specified it.
  339. .. rst-class:: classref-item-separator
  340. ----
  341. .. _class_Engine_method_has_singleton:
  342. .. rst-class:: classref-method
  343. :ref:`bool<class_bool>` **has_singleton** **(** :ref:`StringName<class_StringName>` name **)** |const|
  344. Returns ``true`` if a singleton with given ``name`` exists in global scope.
  345. .. rst-class:: classref-item-separator
  346. ----
  347. .. _class_Engine_method_is_editor_hint:
  348. .. rst-class:: classref-method
  349. :ref:`bool<class_bool>` **is_editor_hint** **(** **)** |const|
  350. Returns ``true`` if the script is currently running inside the editor, ``false`` otherwise. 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:
  351. .. tabs::
  352. .. code-tab:: gdscript
  353. if Engine.is_editor_hint():
  354. draw_gizmos()
  355. else:
  356. simulate_physics()
  357. .. code-tab:: csharp
  358. if (Engine.IsEditorHint())
  359. DrawGizmos();
  360. else
  361. SimulatePhysics();
  362. See :doc:`Running code in the editor <../tutorials/plugins/running_code_in_the_editor>` in the documentation for more information.
  363. \ **Note:** To detect whether the script is run from an editor *build* (e.g. when pressing :kbd:`F5`), use :ref:`OS.has_feature<class_OS_method_has_feature>` with the ``"editor"`` argument instead. ``OS.has_feature("editor")`` will evaluate to ``true`` both when the code is running in the editor and when running the project from the editor, but it will evaluate to ``false`` when the code is run from an exported project.
  364. .. rst-class:: classref-item-separator
  365. ----
  366. .. _class_Engine_method_is_in_physics_frame:
  367. .. rst-class:: classref-method
  368. :ref:`bool<class_bool>` **is_in_physics_frame** **(** **)** |const|
  369. Returns ``true`` if the game is inside the fixed process and physics phase of the game loop.
  370. .. rst-class:: classref-item-separator
  371. ----
  372. .. _class_Engine_method_register_script_language:
  373. .. rst-class:: classref-method
  374. void **register_script_language** **(** :ref:`ScriptLanguage<class_ScriptLanguage>` language **)**
  375. Registers a :ref:`ScriptLanguage<class_ScriptLanguage>` instance to be available with ``ScriptServer``.
  376. .. rst-class:: classref-item-separator
  377. ----
  378. .. _class_Engine_method_register_singleton:
  379. .. rst-class:: classref-method
  380. void **register_singleton** **(** :ref:`StringName<class_StringName>` name, :ref:`Object<class_Object>` instance **)**
  381. Registers the given object as a singleton, globally available under ``name``.
  382. .. rst-class:: classref-item-separator
  383. ----
  384. .. _class_Engine_method_unregister_singleton:
  385. .. rst-class:: classref-method
  386. void **unregister_singleton** **(** :ref:`StringName<class_StringName>` name **)**
  387. Unregisters the singleton registered under ``name``. The singleton object is not freed. Only works with user-defined singletons created with :ref:`register_singleton<class_Engine_method_register_singleton>`.
  388. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  389. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  390. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  391. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  392. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  393. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`