You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Module Initialization - Level Scene is running in-editor #1255
Unfortunately, this is not what MODULE_INITALIZATION_LEVEL_SCENE and MODULE_INITIALIZATION_LEVEL_EDITOR are for. Just like in Godot modules defined in the engine, any nodes that are registered during any initialization level will run in the editor, and they need to call Engine::is_editor_hint() to control what behavior they want to run in editor or not. In general, GDExtensions aim to emulate how Godot modules work, and this is how it works for Godot modules.
The initialization levels have to do with the process of engine startup, so that things are registered in the right order. For example, some aspects of the editor need to be initialized before we can start registering editor-related classes.
However, I understand your frustration! This is the number 2 complaint from people who are trying to use GDExtension to write gameplay code. This is a problem that needs some sort of answer, but we haven't come up with one yet. One possibility we've discussed is allowing developers to register scripts from godot-cpp (rather than extension classes), which would behave much more like GDScript (or GDNative from Godot 3), however, there's been some debate around whether or not this is a good idea.
oh thanks for explaining, asked in the chats nobody gave a deep response like that, which makes sense in my mind now, and yeah, in one of your lives not long ago I shared this proposal: godotengine/godot-proposals#573
not much related to this topic in general, but I just think its strange that you need to check if is editor or not, since _ready and _process for example when attached to a node's gdscript doesnt require you that, as a godot user I expect to run my code in-editor only if I say so @tool. And Module initialization level scene (in my mind) was basically saying to the engine: -hey only initialize this code while a game scene starts xD.
Activity
dsnopek commentedon Sep 28, 2023
Thanks for the feedback!
Unfortunately, this is not what
MODULE_INITALIZATION_LEVEL_SCENEandMODULE_INITIALIZATION_LEVEL_EDITORare for. Just like in Godot modules defined in the engine, any nodes that are registered during any initialization level will run in the editor, and they need to callEngine::is_editor_hint()to control what behavior they want to run in editor or not. In general, GDExtensions aim to emulate how Godot modules work, and this is how it works for Godot modules.The initialization levels have to do with the process of engine startup, so that things are registered in the right order. For example, some aspects of the editor need to be initialized before we can start registering editor-related classes.
However, I understand your frustration! This is the number 2 complaint from people who are trying to use GDExtension to write gameplay code. This is a problem that needs some sort of answer, but we haven't come up with one yet. One possibility we've discussed is allowing developers to register scripts from godot-cpp (rather than extension classes), which would behave much more like GDScript (or GDNative from Godot 3), however, there's been some debate around whether or not this is a good idea.
nonunknown777 commentedon Sep 28, 2023
oh thanks for explaining, asked in the chats nobody gave a deep response like that, which makes sense in my mind now, and yeah, in one of your lives not long ago I shared this proposal: godotengine/godot-proposals#573
not much related to this topic in general, but I just think its strange that you need to check if is editor or not, since
_readyand_processfor example when attached to a node's gdscript doesnt require you that, as a godot user I expect to run my code in-editor only if I say so@tool. And Module initialization level scene (in my mind) was basically saying to the engine: -hey only initialize this code while a game scene starts xD.So this really needs to be discussed!