-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Allow GDExtensions to add editor plugins #77010
Allow GDExtensions to add editor plugins #77010
Conversation
383cdf5
to
54a9d7e
Compare
I've rebased this now that PR #76406 has been merged, made the companion godot-cpp PR (godotengine/godot-cpp#1114) and actually tested that this works. :-) This is now ready for review! |
Discussed this with @dsnopek after last meeting. This seems like a sound solution within the constraints we currently have. My only remaining remark is that this is worth a wider discussion around our limited access to singletons. The "proper" way for this is that we do have access to the Imho we should change this part of cc @vnen |
Thanks, @BastiaanOlij! Just quick clarification on this point:
Core modules actually don't access the Modules register a creation function during registration (via |
Ah gotcha, so really in this case we should be use exposing static functions but thats not really possible in this case because it's using a template. Sigh, some things just don't survive the bridge :) Yeah I'm all ok with this going ahead. I just hope we get around to doing the other thing some day too :) |
I am waiting for this, because until it isn't merged, it is impossible to create advanced plugins with GDExtension ( |
@dsnopek also i can't compile this PR with MSVC, I get this error: It compiles fine with MinGW. Should it be like this? |
I tried to create simple 3d editor: test_editor.h
test_editor.cpp contains empty implementations. When I start a project and create any node, the editor hangs without any errors in the console or anywhere. |
This was fixed in PR #77137 - I'll rebase this PR to include it in a moment.
Hm, I did an even simpler test when working on this, and that worked for me. Later, I'll try with your test class and see what happens. |
54a9d7e
to
7115c0d
Compare
Video: Untitled.mp4There are also some errors in the console, but they appear regardless of whether there is any extension or not. (And they don't seem to affect anything, because when no extension is added to the project, nothing is freezes.) Exactly same code rewritten to GDScript works without any problems. |
Thanks! I'm able to reproduce the issue with your MRP. It seems to be related to the I'll see if I can debug further... |
@anunknowperson The hanging appears to be a regression caused by this godot-cpp PR: godotengine/godot-cpp#1044 - if I reverse the changes that were committed there, then it doesn't hang, and the editor starts up normally! For the details: running the MRP in the debugger, it looks like we're hanging on A related PR for godot-cpp (godotengine/godot-cpp#1045) caused a similar regression, where it fixed calling normal methods, but broke calling virtual methods. This looks to be the same thing! When calling virtual methods, Godot is passing an In any case, that bug is out-of-scope for this PR! As far as I can tell, this PR is correctly registering the editor plugin. |
Yes.
Well, it did fix a legitimate bug, so you'll be getting that bug back, unfortunately. So, it really depends on if your project runs into that bug too. The regressions from godotengine/godot-cpp#1044 and godotengine/godot-cpp#1045 are critical and need to get fixed before Godot 4.1. I'm personally planning to focus my attention on them after the feature freeze next week - until then, we gotta try and finish up any new features (like this editor plugin PR). After the feature freeze, we'll have another 4 weeks to work on bugs. :-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed privately and in the GDExtension meeting. This seems like a clean way to add the ability to register editor plugins properly. Ready to be merged
7115c0d
to
3007163
Compare
Thanks! |
Fixes godotengine/godot-cpp#640
This is an alternative to PR #65592 (but just the GDExtension part) based on some feedback that PR received from the GDExtension team back in December.
It adds two new functions to the
GDExtensionInterface
struct (editor_add_plugin
andeditor_remove_plugin
) which both take aStringName
representing a class registered inClassDB
(since all GDExtension classes need to be registered inClassDB
).This is used in the companion godot-cpp PR: godotengine/godot-cpp#1114
It allows you to use
EditorPlugins::add_by_type<MyEditorPlugin>()
in your GDExtension, in much the same way as you would in a module.If this is called during Godot's initialization process, it's just adding the class name to a list, and the actual editor plugins will be created later in
EditorNode::EditorNode()
, in the same place the built-in editor plugins are created. If it's called after the editor is already initialized, then it'll call straight intoEditorNode::get_singleton()->add_extension_editor_plugin()
.This is currently a draft because:I still need to do the godot-cpp changes and actually test it :-)If PR Rework GDExtension interface from a struct to loading function pointers #76406 is merged, then this'll need to get reworked to use the new way of registering GDExtension interface functions. That PR is more important, so I'm fine saving this one until that one is resolved.For the moment, I'd mainly like to see what others think of this general approach!UPDATE: This is now ready for review!