Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: DuaneDog on March 02, 2014, 04:36:02 AM

Title: Best design to handle button events in a parent script
Post by: DuaneDog on March 02, 2014, 04:36:02 AM
I have a simple first, next, back, last navigation panel. So four buttons inside a panel. What is the best way to trap the click events in the parent script? Or do I need to make a script for each individual button?  I know this is probably very simple but I'm having a hard time tracking down specific documentation on the best practice.
Title: Re: Best design to handle button events in a parent script
Post by: DuaneDog on March 02, 2014, 05:43:15 AM
I ended up using the legacy message event script to handle this.
Title: Re: Best design to handle button events in a parent script
Post by: Nicki on March 02, 2014, 08:15:14 AM
I'd have a controller script on the panel (or where you instantiate the buttons) and add a listener with UIEventListener.

http://pastebin.com/S42AN9ma (since the code tags are messing with me)