Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: capitalj on July 17, 2012, 05:19:33 PM
-
Hi,
I'm wondering whether I need to remove event listeners when a scene has ended, typically I will put in a -= for events in the OnDisable method, but for NGUI events, should I do the same thing:
UIEventListener.Get(myButton).onClick -= UIButtonPressed;
or do these get removed by NGUI?
-JJ
-
Does your UI persist when the scene unloads? Unless you mark your UI Root as "dont destroy on load", it'll be destroyed, so the removal of callbacks is unnecessary.
-
Awesome thanks, yeah the UI does not persist so looks like I don't have to do anything :)
-
followup question:
if such a scenario occurs
currently in scene 1 -> load into scene 2 -> then back to scene 1 after some actions...essentially, scene 1 is my main scene which i will always return to, like a big lobby?
would it be better if i let the UI of scene 1 persists instead of letting it go away?
-
No need. It's better to let Unity release the unneeded resources.
-
thanks.