NGUI EventDelegate

I have a button whose function changes depending on which panel is currently being displayed.  When switching panels, this button stays on screen (think a NavBar).  I ran into this unexpected behavior today, that slowed me down.

If you change the contents of an EventDelegate list during a method called from that  EventDelegate list then its probable that your new method will get called right way when control is passed back to the Execute method of EventDelegate.  This looked like the OnClick method of a UIButton was not waiting for a release, so I went down that rabbit hole for a bit.

I ended up adding a short delay to the code that switches the current OnClick action to the new OnClick action, which solved the problem.

	//delay this by a frame, so it happens outside the EventDelegate processing

Leave a Reply