allow inheriting EditorPlugin
This commit is contained in:
@ -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.
|
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.
|
// 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) {
|
if (script_path.length() > 0) {
|
||||||
script_path = addon_path.get_base_dir().path_join(script_path);
|
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
|
// 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));
|
show_warning(vformat(TTR("Unable to load addon script from path: '%s'. Script is not in tool mode."), script_path));
|
||||||
return;
|
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);
|
ep->set_plugin_version(plugin_version);
|
||||||
addon_name_to_plugin[addon_path] = ep;
|
addon_name_to_plugin[addon_path] = ep;
|
||||||
add_editor_plugin(ep, p_config_changed);
|
add_editor_plugin(ep, p_config_changed);
|
||||||
|
|||||||
Reference in New Issue
Block a user