Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Asse on October 17, 2012, 01:07:08 PM

Title: Keep active state of GameObjects when enabling/disabling complete UIs
Post by: Asse on October 17, 2012, 01:07:08 PM
Did anybody found a good approach to keep the active/inactive state of single UI GameObjects when enabling/disabling complete UIs?

I have several windows which of course consist of many GameObjects with UIWidget behaviours which may be enabled or disabled, depending on logic. Now when a window manager disables and later enables the window using NGUITools.SetActive, all GameObjects are enabled no matter what there active state was when they got disabled. That's clear.

Now did anybody found a way to keep the inactive state? I think of helper scripts or disabling the UIWidget and depending on that the GameObject also doesn't get activated. But I'd like to read some ideas of you guys.
Title: Re: Keep active state of GameObjects when enabling/disabling complete UIs
Post by: Nicki on October 17, 2012, 02:54:51 PM
We have every screen be a "UIScreen", which only has the virtual methods: init,show,hide. Show and Hide has SetActiveRecursively in it. So a more advanced screen would extend/inherit/implement those functions and do more advanced stuff in it. My main screenController will just call init once the first time it's loaded and call show/hide as needed.

If I need certain widgets and colliders to be off, I tend to turn them off on a component basis, as this isn't fucked up by SetActive or SetActiveRecursively.