mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Merge pull request #93296 from rune-scape/editor-node-inheritance
EditorPlugin: Allow instance base type inheriting EditorPlugin
This commit is contained in:
commit
5626f0bf0b
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue