Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module Initialization - Level Scene is running in-editor #1255

Closed
nonunknown777 opened this issue Sep 28, 2023 · 2 comments · Fixed by #1256
Closed

Module Initialization - Level Scene is running in-editor #1255

nonunknown777 opened this issue Sep 28, 2023 · 2 comments · Fixed by #1256

Comments

@nonunknown777
Copy link

Godot version

4.1 stable

godot-cpp version

4.1

System information

Linux

Issue description

When running the code with:

MODULE_INITIALIZATION_LEVEL_SCENE

the code runs in-editor, but that should only happens if the dev uses:

MODULE_INITIALIZATION_LEVEL_EDITOR

Steps to reproduce

  • Create GDExtension project
  • set initialization to: MODULE_INITIALIZATION_LEVEL_SCENE
  • open project
  • the code will be running in-editor

Minimal reproduction project

NA

@dsnopek
Copy link
Collaborator

dsnopek commented Sep 28, 2023

Thanks for the feedback!

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.

@nonunknown777
Copy link
Author

nonunknown777 commented 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 _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.

So this really needs to be discussed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants