Closed hsandt closed 1 month ago
Here is a commit on the game I'm currently working on, which contains the mentioned fix, as well as some changes in error messages: https://github.com/hsandt/lospec-jam-2-scaled-down-adventures/commit/007a7a1e2159c2794f84cc1f14c164a09193b260
Thank you for catching this and sharing your fix.
I pushed a change that followed a similar convention to the _process()
loop. I believe it fixes the issue, but I currently don't have a scene setup to test this case. Feel free to re-open if the bug persists, or if I've created a new one.
After adding a custom script that was referencing some scene A in order to load it manually, I noticed that the main menu Play button stopped loading scene A as the initial scene.
Debugging
SceneLoader.load_scene
shows that the block checkingif ResourceLoader.has_cached(scene_path):
only sends a signal, then returns:and in general you don't have custom code plugged to
scene_loaded
, so nothing more happens.To fix this, I defined the following function:
and added the following line before
return
:I added
call_deferred
to follow the logic of the existing linecall_deferred("emit_signal", "scene_loaded")
although it didn't seem necessary in this case, but always safer to change scene on deferred call anyway.I suspect that the dev's intention was to mimic background loading, where we would emit a signal and let the user plug some custom behavior there. However, it seems unnecessary when the scene is already cached since it wouldn't take more than 1 frame.
So I should probably remove the
scene_loaded
signal which would be irrelevant when directly changing to new scene.