Author Topic: Using Event Listeners?  (Read 1880 times)

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Using Event Listeners?
« on: August 13, 2012, 05:45:30 AM »
I'm sure the functionality is in here, and I'm seeing pieces, but I cant quite figure it out...

Basically, I'm making a whole bunch of buttons and it seems kind of silly to attach a script to all of them that does the exact same thing: tells the menuHandlerScript which button was clicked.

I was udner the impression clicking any button sends out an event, so how do I just have a script that listens for any onClick event then - by reading what gameobject/whatever was clicked, reacts?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Using Event Listeners?
« Reply #1 on: August 13, 2012, 08:38:13 AM »
You can use UIEventListener.Get(buttonGameObject).onClick += CallbackFunction;