Author Topic: [SOLVED] Best way/pattern to exchange messages between UI elements?  (Read 1984 times)

vexe

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 153
    • View Profile
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.
« Last Edit: September 10, 2013, 08:33:28 AM by vexe »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
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 () {}"