From e33562fe9f9fc526a3352652f08cd2c322f6ca8a Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 10 Apr 2021 19:18:32 +0200 Subject: [PATCH] Improve the `Engine.editor_hint` property documentation (cherry picked from commit 17591fc6a1aaa530f54b4950860afccff6f13f7a) --- doc/classes/Engine.xml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 776d95e120..e26ed6dc6f 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -144,7 +144,15 @@ - If [code]true[/code], it is running inside the editor. Useful for tool scripts. + If [code]true[/code], the script is currently running inside the editor. This is useful for [code]tool[/code] scripts to conditionally draw editor helpers, or prevent accidentally running "game" code that would affect the scene state while in the editor: + [codeblock] + if Engine.editor_hint: + draw_gizmos() + else: + simulate_physics() + [/codeblock] + See [url=https://docs.godotengine.org/en/stable/tutorials/misc/running_code_in_the_editor.html]Running code in the editor[/url] in the documentation for more information. + [b]Note:[/b] To detect whether the script is run from an editor [i]build[/i] (e.g. when pressing [code]F5[/code]), use [method OS.has_feature] with the [code]"editor"[/code] argument instead. [code]OS.has_feature("editor")[/code] will evaluate to [code]true[/code] both when the code is running in the editor and when running the project from the editor, but it will evaluate to [code]false[/code] when the code is run from an exported project. The number of fixed iterations per second. This controls how often physics simulation and [method Node._physics_process] methods are run. This value should generally always be set to [code]60[/code] or above, as Godot doesn't interpolate the physics step. As a result, values lower than [code]60[/code] will look stuttery. This value can be increased to make input more reactive or work around tunneling issues, but keep in mind doing so will increase CPU usage.