Skip to content

Commit ea1aec2

Browse files
committed
Merge pull request godotengine#112193 from KnifeXRage/autoload_with_uids
Autoloads with UIDs
2 parents febd1d3 + d940614 commit ea1aec2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

editor/settings/editor_autoload_settings.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,14 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
395395
scn.instantiate();
396396
scn->set_path(p_path);
397397
scn->reload_from_file();
398-
ERR_FAIL_COND_V_MSG(scn.is_null(), nullptr, vformat("Failed to create an autoload, can't load from path: %s.", p_path));
398+
ERR_FAIL_COND_V_MSG(scn.is_null(), nullptr, vformat("Failed to create an autoload, can't load from UID or path: %s.", p_path));
399399

400400
if (scn.is_valid()) {
401401
n = scn->instantiate();
402402
}
403403
} else {
404404
Ref<Resource> res = ResourceLoader::load(p_path);
405-
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, vformat("Failed to create an autoload, can't load from path: %s.", p_path));
405+
ERR_FAIL_COND_V_MSG(res.is_null(), nullptr, vformat("Failed to create an autoload, can't load from UID or path: %s.", p_path));
406406

407407
Ref<Script> scr = res;
408408
if (scr.is_valid()) {
@@ -427,7 +427,7 @@ Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {
427427

428428
void EditorAutoloadSettings::init_autoloads() {
429429
for (AutoloadInfo &info : autoload_cache) {
430-
info.node = _create_autoload(info.path);
430+
info.node = _create_autoload(ResourceUID::ensure_path(info.path));
431431

432432
if (info.node) {
433433
Ref<Script> scr = info.node->get_script();
@@ -498,7 +498,7 @@ void EditorAutoloadSettings::update_autoload() {
498498
}
499499

500500
info.name = name;
501-
info.path = scr_path;
501+
info.path = ResourceUID::get_singleton()->path_to_uid(scr_path);
502502
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
503503

504504
bool need_to_add = true;
@@ -530,7 +530,7 @@ void EditorAutoloadSettings::update_autoload() {
530530
item->set_text(0, name);
531531
item->set_editable(0, true);
532532

533-
item->set_text(1, scr_path);
533+
item->set_text(1, ResourceUID::ensure_path(scr_path));
534534
item->set_selectable(1, true);
535535

536536
item->set_cell_mode(2, TreeItem::CELL_MODE_CHECK);
@@ -800,7 +800,7 @@ bool EditorAutoloadSettings::autoload_add(const String &p_name, const String &p_
800800

801801
undo_redo->create_action(TTR("Add Autoload"));
802802
// Singleton autoloads are represented with a leading "*" in their path.
803-
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + p_path);
803+
undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + ResourceUID::get_singleton()->path_to_uid(p_path));
804804

805805
if (ProjectSettings::get_singleton()->has_setting(name)) {
806806
undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, GLOBAL_GET(name));
@@ -876,7 +876,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
876876
}
877877

878878
info.name = name;
879-
info.path = scr_path;
879+
info.path = ResourceUID::get_singleton()->path_to_uid(scr_path);
880880
info.order = ProjectSettings::get_singleton()->get_order(pi.name);
881881

882882
if (info.is_singleton) {

main/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4275,7 +4275,7 @@ int Main::start() {
42754275
// Cache the scene reference before loading it (for cyclic references)
42764276
Ref<PackedScene> scn;
42774277
scn.instantiate();
4278-
scn->set_path(info.path);
4278+
scn->set_path(ResourceUID::ensure_path(info.path));
42794279
scn->reload_from_file();
42804280
ERR_CONTINUE_MSG(scn.is_null(), vformat("Failed to instantiate an autoload, can't load from path: %s.", info.path));
42814281

modules/gdscript/tests/gdscript_test_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void init_autoloads() {
7676
// Cache the scene reference before loading it (for cyclic references)
7777
Ref<PackedScene> scn;
7878
scn.instantiate();
79-
scn->set_path(info.path);
79+
scn->set_path(ResourceUID::ensure_path(info.path));
8080
scn->reload_from_file();
8181
ERR_CONTINUE_MSG(scn.is_null(), vformat("Failed to instantiate an autoload, can't load from path: %s.", info.path));
8282

0 commit comments

Comments
 (0)