Deactivate/activate Pages vs Instantiating

Hi, I’m making a mobile game and for my UI I am trying to decide if switching between UI pages if I should activate and deactivate previous pages rather than Instantiating and destroying them when switching. My main concern is if I only activate and deactivate as my UI grows I’ll start using too much memory with game objects sitting there but I’m not really sure how realistic that is, and if Instantiating pages will be too slow. Can anyone with experience on this enlighten me witch method is a better practice in Unity?

I think you understand the problems with both approaches and it comes down to how you use them in your game. In my experiences, instantiation is a slow process that reduces the fluidity of your game more than keeping the windows disabled. If you have a lot of textures, you can save some space by unloading the textures when the window is hidden. This doesn’t matter so much for atlases as they most likely will always be loaded. You will of course still have a hitch when the textures are reloaded but at least this doesn’t have the overhead of creating new game objects and deserializing the properties from a prefab.

From general discussions another way to get snappy performance is to simply shift the layer of the UI to one that is not rendered.

As always, profile on your target device to check performance.

Thanks for the input guys. For now I’m leaving all the game objects there, deactivating them as necessary and I’ll keep an eye on performance. Tonight I’m going to duplicate one of my UI pages to the total number of pages I believe my game will need and see if I see a performance drop with those objects sitting there deactivated.