Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add relative path support for EditorPlugin::add_autoload_singleton #78109

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion editor/editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down