Explorar o código

[godot#68971] Fetch cached scene if it exists in `GDScriptCache`

Adam Scott %!s(int64=2) %!d(string=hai) anos
pai
achega
e86e15571f
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      modules/gdscript/gdscript_cache.cpp

+ 6 - 1
modules/gdscript/gdscript_cache.cpp

@@ -342,7 +342,12 @@ Ref<PackedScene> GDScriptCache::get_packed_scene(const String &p_path, Error &r_
 		return singleton->packed_scene_cache[p_path];
 	}
 
-	Ref<PackedScene> scene;
+	Ref<PackedScene> scene = ResourceCache::get_ref(p_path);
+	if (scene.is_valid()) {
+		singleton->packed_scene_cache[p_path] = scene;
+		singleton->packed_scene_dependencies[p_path].insert(p_owner);
+		return scene;
+	}
 	scene.instantiate();
 
 	r_error = OK;