Skip to content

Commit d779c98

Browse files
committed
allow inheriting EditorPlugin
1 parent 6efa557 commit d779c98

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
@@ -4043,6 +4043,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
40434043
Ref<Script> scr; // We need to save it for creating "ep" below.
40444044

40454045
// Only try to load the script if it has a name. Else, the plugin has no init script.
4046+
EditorPlugin *ep = nullptr;
40464047
if (script_path.length() > 0) {
40474048
script_path = addon_path.get_base_dir().path_join(script_path);
40484049
// We should not use the cached version on startup to prevent a script reload
@@ -4077,10 +4078,15 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
40774078
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. Script is not in tool mode."), script_path));
40784079
return;
40794080
}
4081+
4082+
Object *obj = ClassDB::instantiate(scr->get_instance_base_type());
4083+
ep = Object::cast_to<EditorPlugin>(obj);
4084+
ERR_FAIL_NULL(ep);
4085+
ep->set_script(scr);
4086+
} else {
4087+
ep = memnew(EditorPlugin);
40804088
}
40814089

4082-
EditorPlugin *ep = memnew(EditorPlugin);
4083-
ep->set_script(scr);
40844090
ep->set_plugin_version(plugin_version);
40854091
addon_name_to_plugin[addon_path] = ep;
40864092
add_editor_plugin(ep, p_config_changed);

0 commit comments

Comments
 (0)