From a700316a11c8943f64a56d60ffc2db1c82586e4b Mon Sep 17 00:00:00 2001 From: dusk Date: Sun, 8 Dec 2024 02:40:22 +0300 Subject: [PATCH] fix(scenes): process cached scenes properly --- addons/scenes/scenes.gd | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/scenes/scenes.gd b/addons/scenes/scenes.gd index 6bbc7b5..979d9d8 100644 --- a/addons/scenes/scenes.gd +++ b/addons/scenes/scenes.gd @@ -47,7 +47,11 @@ func _set_new_scene(resource: PackedScene) -> void: ## (and any other signal) otherwise it will run every time a scene is changed. func change_scene_to(path: String, params = {}) -> Signal: _params = params - _loader_mt.resource_loaded.connect(_set_new_scene, CONNECT_ONE_SHOT) - _loader_mt.load_resource(path) + var maybe_resource = _loader_mt.load_resource(path) change_started.emit(path, params) + if maybe_resource: + call_deferred("_set_new_scene", maybe_resource) + return scene_changed + else: + _loader_mt.resource_loaded.connect(_set_new_scene, CONNECT_ONE_SHOT) return scene_changed