Proper way to unload a scene and load a new scene ?

Feb 11, 2012 at 4:24 PM


What is the proper way to unload a scene and load a new Scene (level transition) ?

With Sunburn just call "sceneInterface.Clear()" and load a new level but with "Indie Freaks" this method not works.

In fact when i call "Application.Sunburn.Clear()" by a click in a gui button, an exception is throwed by the GuiManager in the Update method :
"Collection was modified; enumeration operation may not execute."

because the "clear()" method of the gui manager clear all the screens regardless if screens are currently being updated.

I think the GuiManager was been changed to execute "add", "remove" and "clear" actions in the "update" method to avoid this issue.

What do you think of that ?

Thank you

Feb 11, 2012 at 8:38 PM

I probably should work on caching the clearing/adding/removing actions execution at the end of the GuiManager Screen processing loop. I'll look onto it.

Until then, the way I actually properly unload/load scenes is using a Timer:

Timer.Create(1f, false, tick =>

                                            Application.LoadGameState(new PlayGameState(Application), new PleaseWaitGameState(Application));