Godot Engine – Multi-platform 2D and 3D game engine
Reuse cached scene resource if already opened in editor when creating autoloads
Leandro (cerberus1746) Benedet Garcia26704f88e74c
diff --git a/editor/settings/editor_autoload_settings.cpp b/editor/settings/editor_autoload_settings.cppindex 20738db1232..22adfddf5de 100644--- a/editor/settings/editor_autoload_settings.cpp+++ b/editor/settings/editor_autoload_settings.cpp@@ -332,16 +332,10 @@ void EditorAutoloadSettings::_autoload_open(const String &fpath) {Node *EditorAutoloadSettings::_create_autoload(const String &p_path) {Node *n = nullptr;if (ResourceLoader::get_resource_type(p_path) == "PackedScene") {- // Cache the scene reference before loading it (for cyclic references)- Ref<PackedScene> scn;- scn.instantiate();- scn->set_path(ResourceUID::ensure_path(p_path));- scn->reload_from_file();+ Ref<PackedScene> scn = ResourceLoader::load(p_path);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));- if (scn.is_valid()) {- n = scn->instantiate();- }+ n = scn->instantiate();} else {Ref<Resource> res = ResourceLoader::load(p_path);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));