Xerios / ScreenManager

Flexible way to manage screens with transitions for Unity
MIT License
563 stars 69 forks source link

Is there any problem with Screen Manager Stack #1

Closed takaaptech closed 7 years ago

takaaptech commented 7 years ago

First of all, i think it is the simple and awesome solution! Thank so much for this lib! My game have 3 screens: Menu, MainGame, GameOver and i using screenmgr.Show("SceneName") for changing between screens. When user plays a lot, i see on editor the Stack contains many screens. Is this problem for memory or GC? Is there any way to reduce stack in this case or this design is for some purpose? Thank so much!

Xerios commented 7 years ago

Thanks, I'm glad you find it useful :)

Well, the stack is there so that you can go back in the menu ( think of it like the browser's back button ) and also it's for the manager to keep track of what's open. In your situation, keeping the stack won't give you any advantage, so here's my advice:

The stack shouldn't have any serious performance impacts since the screens are reused, but the fact that it's filling up is most probably because you're not closing your screens, instead you're opening new ones on top of older ones. You can also use HideAll(), which will clear the stack and close all screens.

Hope it helps !

takaaptech commented 7 years ago

Hi @Xerios, I see Hide() very helpful in my case, after test, i see another problem (just in my case, not the lib): In Game Over, I have a button that can go back to home (Main Menu), also has Retry button to go back to InGame. In Menu we have Play button to go direct to InGame. In Retry button (Game Over) i try using Hide() function. So if we have chain like this: Menu -> InGame -> GameOver - > Menu -> Ingame -> GameOver -> this time press Retry will show GameOver again. So maybe if from GameOver we can go to both Menu and Ingame, then we should use show instead?

Xerios commented 7 years ago

I'll be uploading new functionality and a demo that will cover your case, really soon :)

takaaptech commented 7 years ago

Opp! Sorry for delay closing it. I tested and it works as expected! Thank so much!