-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Enable EditorPlugin
added by modules and GDExtensions (reverted)
#90608
Merged
akien-mga
merged 1 commit into
godotengine:master
from
raulsntos:editor/enable-plugin-after-adding
May 2, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3492,6 +3492,7 @@ void EditorNode::add_extension_editor_plugin(const StringName &p_class_name) { | |
EditorPlugin *plugin = Object::cast_to<EditorPlugin>(ClassDB::instantiate(p_class_name)); | ||
singleton->editor_data.add_extension_editor_plugin(p_class_name, plugin); | ||
add_editor_plugin(plugin); | ||
plugin->enable_plugin(); | ||
} | ||
|
||
void EditorNode::remove_extension_editor_plugin(const StringName &p_class_name) { | ||
|
@@ -7217,7 +7218,9 @@ EditorNode::EditorNode() { | |
add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); | ||
|
||
for (int i = 0; i < EditorPlugins::get_plugin_count(); i++) { | ||
add_editor_plugin(EditorPlugins::create(i)); | ||
EditorPlugin *plugin = EditorPlugins::create(i); | ||
add_editor_plugin(plugin); | ||
plugin->enable_plugin(); | ||
Comment on lines
+7222
to
+7223
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
} | ||
|
||
for (const StringName &extension_class_name : GDExtensionEditorPlugins::get_extension_classes()) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
As @kisg points out, we could alternatively implement this by doing:
If we do that, though, we'd probably want to change the name of that argument, since the name is currently
p_config_changed
, which doesn't make sense in this context.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.
Yeah, I was thinking that, even though
p_config_changed
is currently only used to determine ifenable_plugin()
is called, it may be used for more stuff in the future and I didn't want to change its meaning. But I'm happy to change it if we're fine with that.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.
The current logic for
p_config_changed
seems to be a toggle for on/off:add_editor_plugin
enables the plugin ifp_config_changed
, andremove_editor_plugin
disables the plugin ifp_config_changed
.So I think we can rely on that behavior, but I'd rename the bool in
add_editor_plugin
andremove_editor_plugin
respectively top_enable_plugin
andp_disable_plugin
.That's being said I'm a bit confused about the difference between adding and enabling, and removing and disabling. Especially the latter two - can one remove a plugin without it being also disabled?
Edit: Shouldn't be blocking for this PR though IMO, this can be tweaked later.
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.
CC @KoBeWi
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.
One can add a plugin but not enable it (see the Activate now checkbox when creating GDScript plugins). You can also always enable/disable plugins from project settings.
GDExtension and module plugins don't really allow enabling/disabling plugins1, I think it's implied that these plugins are always enabled when added and disabled when removed. But before this PR the
_enable_plugin
and_disable_plugin
virtual methods were never called.The motivation behind this PR was to maintain consistency with the current scripting behavior in GDExtension plugins. This is important to me since I want to avoid behavior changes for the .NET bindings when moving from scripting to GDExtension.
I agree about removing without disabling being confusing, I'd assume removing always imply disabling. I forgot about disabling in this PR though, because the .NET plugin I'm working on doesn't override
_disable_plugin
so I didn't notice.Footnotes
This may change in the future for GDExtensions, since the GDExtension team wants to allow enabling/disabling GDExtensions in project settings. ↩
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.
Oh, then this PR is wrong.
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.
So should this be reverted then?
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.
You mean the whole PR or just this change? (or it's the same, idk)
I described the expected behavior, so the current one should be tweaked if it's different.
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.
Yeah, it's the same. If we don't want GDExtension EditorPlugins to have
_enable_plugin
called when Godot is launched, then we should revert the PR. But that means_enable_plugin
will never be called for GDExtension EditorPlugins since we have no way of enabling them (I guess they are considered to be pre-enabled when they are added).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.
There is enter tree callback called on editor launch, so this use-case is covered.
_enable_plugin
is for when user enables a plugin, and if GDExtensions can't be toggled, this callback is not for them.