1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-04 17:04:49 +00:00

allow inheriting EditorPlugin

This commit is contained in:
rune-scape
2024-06-17 10:14:14 -07:00
parent 6efa557e9b
commit d779c98ee1

View File

@@ -4043,6 +4043,7 @@ void EditorNode::set_addon_plugin_enabled(const String &p_addon, bool p_enabled,
Ref<Script> scr; // We need to save it for creating "ep" below.
// Only try to load the script if it has a name. Else, the plugin has no init script.
EditorPlugin *ep = nullptr;
if (script_path.length() > 0) {
script_path = addon_path.get_base_dir().path_join(script_path);
// 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,
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. Script is not in tool mode."), script_path));
return;
}
Object *obj = ClassDB::instantiate(scr->get_instance_base_type());
ep = Object::cast_to<EditorPlugin>(obj);
ERR_FAIL_NULL(ep);
ep->set_script(scr);
} else {
ep = memnew(EditorPlugin);
}
EditorPlugin *ep = memnew(EditorPlugin);
ep->set_script(scr);
ep->set_plugin_version(plugin_version);
addon_name_to_plugin[addon_path] = ep;
add_editor_plugin(ep, p_config_changed);