Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: vexe on September 10, 2013, 03:35:08 AM

Title: [SOLVED] Best way/pattern to exchange messages between UI elements?
Post by: vexe on September 10, 2013, 03:35:08 AM
I have asked the question here << http://answers.unity3d.com/questions/533602/best-waypattern-to-exchange-messages-between-gui-e.html >> I got an answer, but it wasn't that good. I can't send parameters to my functions with UIButtonMessage.

So, what do you think the best way to communicate with UI elements?

- Thanks.
Title: Re: Best way/pattern to exchange messages between UI elements (buttons, windows etc)
Post by: ArenMook on September 10, 2013, 06:59:50 AM
UIButtonMessage passes a game object as the parameter, which is the source game object that triggered the callback.

From that you can GetComponent<> whatever you want. If you need more, don't use UIButtonMessage. Write your own event handler. For example, to handle a click event, just write a script that contains "void OnClick () {}"