This is my loading screen code.
func _ready():
ResourceLoader.load_threaded_request(Brain.next_scene)
func _process(delta):
var progress = []
ResourceLoader.load_threaded_get_status(Brain.next_scene, progress)
%Progress.text = str(progress[0]*100) + "%"
if progress[0] == 1:
var packed_scene = ResourceLoader.load_threaded_get(Brain.next_scene)
get_tree().change_scene_to_packed(packed_scene)```
I made it to load the main game from the main menu, and it does that fine. Whenever a node wants to load, it'll call this simple function in my data management autoload script called `Brain`:
```func loadscene(scene: String):
next_scene = scene
get_tree().change_scene_to_packed(loadingscreen)```
Which will bring up the loading screen and run the code from the beginning. However, I've just added a button to go back to the main menu from the main game scene... and it's not working, it gets stuck on 0.
I'm assuming this has something to do with the code assuming that whatever it's trying to run needs to be loaded from nothing, and it can't handle bringing up scenes that have already been used once before. How best should I change it to enable returning to the main menu?
(The main menu is simple 2D and the main game screen is a 3D scene that takes about 2 seconds to load, if that helps any. If I should be doing any 'unloading' in these processes, I'd like to know about that, too...)