Closed RedwanFox closed 7 months ago
You probably need to check for Engine::get_singleton()->is_editor_hint()
before printing in _process
(or perform an early return
this way).
Read about it, I think it should be mentioned in documentation. Or maybe some helper functions. Godot documentation also mentions that it's possible to check via feature tags https://docs.godotengine.org/en/latest/tutorials/export/feature_tags.html
Something like:
bool is_in_editor() const; // true in editor
bool is_play_in_editor() const; // true if game is played from editor ( or run from build with "editor" feature)
bool is_client() const; // standalone build
bool is_dedicated() const; // or is_server(). headless server build
or
enum class PlayType
{
Editor,
PlayInEditor,
Standalone,
Server
}
PlayType get_play_type() const;
Godot documentation also mentions that it's possible to check via feature tags docs.godotengine.org/en/latest/tutorials/export/feature_tags.html
Built-in feature tags are defined at compile-time. The editor
feature tag does not behave like Engine.is_editor_hint()
, as the editor
feature tag will always be true
whenever a project is run from an editor binary.
That's why I have separated is_in_editor
and is_play_in_editor
in my example of helpers
As mentionned there I think the behavior should be the same as not-tool GDScript, unless a runtime or at least creation time accessor stating if the note type in question is or not a tool, is handled by the engine.
GDExtensions are ideally meant to work like Godot modules. In a Godot module, nodes always run as if they are marked with @tool
, and they use Engine::get_singleton()->is_editor_hint()
(as mentioned by Calinou in the first comment) to check if they are currently running in the editor. Yes, this is different than GDScript, but I believe this is by design.
GDExtensions are ideally meant to work like Godot modules. In a Godot module, nodes always run as if they are marked with
@tool
, and they useEngine::get_singleton()->is_editor_hint()
(as mentioned by Calinou in the first comment) to check if they are currently running in the editor. Yes, this is different than GDScript, but I believe this is by design.
Ok thanks that explains it, I wasnt aware of that.
Godot-cpp commit 8ead641b086b4c3034fc611854f38e516659aec1 godot4 commit be52c5bf6ee7f8e1181f42f7c68fca9f8aaaa2b6 Windows 10
Using example code below place Example node in scene tree in editor and it will be spamming in log as if it was tool class.
Are there any flags or other correct way to register runtime only class?