-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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 more than one EditorPlugin per addon, support GDExtension classes #65592
base: master
Are you sure you want to change the base?
Conversation
feae179
to
6cb4537
Compare
6cb4537
to
0b07b16
Compare
Vector<String> plugin_classes; | ||
if (cf->has_section_key("plugin", "script")) { | ||
// Backward compatibility | ||
plugin_classes.push_back(cf->get_value("plugin", "script")); |
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.
Compatibility code should be wrapped in #ifndef DISABLE_DEPRECATED
Needs rebase. |
Splitting this would be weird, because GDExtension support is done through the feature itself, as a result of handling class names and not just scripts. If I were to split, I'd have no way to make another PR without pretty much rewriting this one. Also, most of GDExtension concerns aren't directly about the PR itself, but about in-editor GDExtension classes in general. I mentionned them here for awareness. |
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.
These changes look good to me. Having capability to use GDExtension in an EditorPlugin is essential.
return; | ||
} | ||
// if (plugin_classes.size() == 0) { |
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.
This commented out code can be removed.
plugin_classes.push_back(cf->get_value("plugin", "script")); | ||
|
||
} else if (cf->has_section_key("plugin", "editor_plugins")) { | ||
Array array = cf->get_value("plugin", "script"); |
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.
That's a mistake. Should be Array array = cf->get_value("plugin", "editor_plugins");
We approved the feature in the GDExtension PR review meeting. The comment by @KoBeWi should be addressed though, as compatibility features should always be surrounded by Another feedback is that the logic for selecting either Regarding the support of class names in the list, we are not really convinced this is the best way to implement it. Modules usually register themselves as plugins by calling |
I was thinking of this alternative of just exposing two functions to add and remove plugins, but it seems the function we currently use in modules wouldn't really work on its own. Besides, there is no The difference with modules is that modules registering plugins with If we go for exposing Regarding not exposing editor classes, I would not couple the fact they are not exposed with (I can fix the PR but I'd like to be sure of the design) |
For the GDExtension part of this, I see at least three possible approaches (the last two are just restating what @Zylann describes above in their last comment):
So, I think option nr 1 or 2 are the better way to go. Does anyone have a preference? Or, any other implementation ideas? |
Despite what I wrote in my last comment yesterday, I ended up trying out an implementation that is closer to option nr 3, but done in away to avoid it's downsides (ie. fully supporting adding and removing editor plugins at any time, including engine initialization/deinitialization). Here's the draft PR: #77010 I did start to implement the other options but abandoned them for various reasons:
|
Implements godotengine/godot-proposals#3782
I initially wanted to work on allowing GDExtension to register EditorPlugins (without the need for a proxy script), but because I also need more than one, I figured the proposal above could be done at the same time. So it could also solve godotengine/godot-cpp#640
This adds support for a new
editor_plugins
key inplugin.cfg
, which contains an array of strings. Each string can either be a path to a script (if it contains a.
), or a class name present inClassDB
. The latter allows extensions to registerEditorPlugins
.I left the old
script
key for backward compatibility, but could be removed eventually, or kept for convenience.The way this work also means addons implemented using GDExtension can be turned on and off the like script-based ones.
There are a few issues:
EditorPlugin
have to be registered inClassDB
for this to work. But it seems it would expose them to the Add Node dialog for example, which is not desired. Maybe it needs a new argument toregister_class
in the GDExtension API, unless that already exists?ClassDB::is_extension_class
?