diff options
author | heppocogne <83043568+heppocogne@users.noreply.github.com> | 2023-06-12 21:27:46 +0900 |
---|---|---|
committer | heppocogne <83043568+heppocogne@users.noreply.github.com> | 2023-06-12 21:27:46 +0900 |
commit | f7f4e53763b65290493389a0a657b52863f1e958 (patch) | |
tree | c2fcc9bf6a14df4e45ade441787988b21b0ca57c /editor/editor_plugin.cpp | |
parent | 37d1dfef9d81aade27ab0c56fc6b6f12f6a08045 (diff) | |
download | redot-engine-f7f4e53763b65290493389a0a657b52863f1e958.tar.gz |
Add relative path support for `EditorPlugin::add_autoload_singleton`
Diffstat (limited to 'editor/editor_plugin.cpp')
-rw-r--r-- | editor/editor_plugin.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 9e22a0ead6..4232eacd76 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -62,7 +62,14 @@ void EditorPlugin::remove_custom_type(const String &p_type) { } void EditorPlugin::add_autoload_singleton(const String &p_name, const String &p_path) { - EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path); + if (p_path.begins_with("res://")) { + EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, p_path); + } else { + const Ref<Script> plugin_script = static_cast<Ref<Script>>(get_script()); + ERR_FAIL_COND(plugin_script.is_null()); + const String script_base_path = plugin_script->get_path().get_base_dir(); + EditorNode::get_singleton()->get_project_settings()->get_autoload_settings()->autoload_add(p_name, script_base_path.path_join(p_path)); + } } void EditorPlugin::remove_autoload_singleton(const String &p_name) { |