|
@@ -4067,6 +4067,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
|
|
@@ -4101,10 +4102,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);
|