Skip to content

Commit 5626f0b

Browse files
committed
Merge pull request #93296 from rune-scape/editor-node-inheritance
EditorPlugin: Allow instance base type inheriting EditorPlugin
2 parents 8276e51 + d779c98 commit 5626f0b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

editor/editor_node.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,6 +4067,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
40674067
Ref<Script> scr; // We need to save it for creating "ep" below.
40684068

40694069
// Only try to load the script if it has a name. Else, the plugin has no init script.
4070+
EditorPlugin *ep = nullptr;
40704071
if (script_path.length() > 0) {
40714072
script_path = addon_path.get_base_dir().path_join(script_path);
40724073
// We should not use the cached version on startup to prevent a script reload
@@ -4101,10 +4102,15 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
41014102
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. Script is not in tool mode."), script_path));
41024103
return;
41034104
}
4105+
4106+
Object *obj = ClassDB::instantiate(scr->get_instance_base_type());
4107+
ep = Object::cast_to<EditorPlugin>(obj);
4108+
ERR_FAIL_NULL(ep);
4109+
ep->set_script(scr);
4110+
} else {
4111+
ep = memnew(EditorPlugin);
41044112
}
41054113

4106-
EditorPlugin *ep = memnew(EditorPlugin);
4107-
ep->set_script(scr);
41084114
ep->set_plugin_version(plugin_version);
41094115
addon_name_to_plugin[addon_path] = ep;
41104116
add_editor_plugin(ep, p_config_changed);

0 commit comments

Comments
 (0)