The collection could not be unloaded since it was never loaded (SOLVED)

#1

I am developing a game that have 4 collections: menu, credit, game and game over collection. I follow the tutorial but it have only 2 scenes that call each other. In my case, I have 3 scenes
In the menu scene I have 2 options in the gui start and credit. In the game over scene I have restart and menu option. When I click credit in menu, it will load the credit scene but when I click back to menu I see this error

ERROR:GAMESYS: The collection /scenes/game_over/game_over.collectionc could not be unloaded since it was never loaded. Message ‘unload’ sent from controller:/loader_controller#controller to controller:/loader_controller#game_over_proxy.

I see the same error when I click menu in game over scene

ERROR:GAMESYS: The collection /scenes/credit/credit.collectionc could not be unloaded since it was never loaded. Message ‘unload’ sent from controller:/loader_controller#controller to controller:/loader_controller#credit_proxy.

This is my code

if message_id == hash(“show_menu”) then
msg.post("#menu_proxy", “load”)
msg.post("#game_over_proxy", “unload”)
msg.post("#credit_proxy", “unload”)
end

0 Likes

#2
msg.post("#game_over_proxy", “unload”)
msg.post("#credit_proxy", “unload”)

These two lines will be throwing an error if you haven’t loaded these collections using the “load” message.

I suggest you keep some state variable to keep track of what collections you have actually loaded.

0 Likes

#3

When I receive the proxy_loaded message, I can save the sender to a local variable and call it to unload when I load the new collection, right?

0 Likes

#4

Yes, exactly, but remember that that “local” must be in the scope where you are trying to use it ofc.

0 Likes

#5

Here’s another example of loading and unloading screens with a controller script that tracks the state:

0 Likes

#6

@britzl I follow your example but my collection refer to 2 other collections and it causes the error above.

0 Likes

#7

Yes, but as Matthias points out, you unload two collections, credits and game. Are both loaded? If not, then unload just the one that is loaded.

1 Like

#8

@britzl Both credit and game over collection refer to menu collection. If I am back to menu from credit, it will unload credit but game over has not been loaded yet. Vice versa for game over collection. And @Mathias_Westerdahl solution worked well. Thank you guys

1 Like