-
-
Notifications
You must be signed in to change notification settings - Fork 198
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
No longer run Rust classes inside Godot editor #365
Conversation
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-365 |
Merging since I need the changes for follow-up work, but feel free to leave feedback! |
Add enum EditorRunBehavior to configure semantics.
4392da7
to
49fc088
Compare
Required for OnceCell/OnceLock, which are needed for EditorRunBehavior and will likely play an important role in safe access to global handles.
I figured game classes also benefit from running inside editor, occasionally. I think them similar to how @tool scripts work in gdscript. Might not worth the hussle, but having a way to register classes as "tool classes" and allowing them to run in editor might be preferable to Full vs. NoVirtuals in some places. |
Yep, I was considering per-class as well (also why I made the behavior an enum and not bool). One possibility would be something like this: #[derive(GodotClass)]
#[class(init, base=Node, tool)]
struct MyClass {
...
} And then the global config: #[gdextension]
unsafe impl ExtensionLibrary for DodgeTheCreeps {
fn editor_run_behavior() -> EditorRunBehavior {
EditorRunBehavior::ToolsOnly
}
} Probably this should be the default. Under that design, would it even be useful to have |
Yeah, that would be perfect!
I don't think so. No real usecase came into my mind |
@kulkalkul "tool classes" are implemented in #374. |
Yeah, that's way better, thanks! |
Closes #70.
Closes #132.
Raises MSRV from 1.66 to 1.70.
So far, the workaround to prevent Rust classes from running in the editor was:
With this PR, this is no longer necessary. By default, all virtual callbacks (
ready
,process
etc.) are no longer invoked.Note that classes will still be registered (this is necessary as scene trees would be broken otherwise).
This is still quite rudimentary and can be refined over time, but it should already improve the user experience.
The old behavior -- which may be desired by plugins/extensions rather than games -- can be restored with a configuration in the init trait:
See API Docs for more information.