Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: bodosaher on May 10, 2014, 08:11:34 AM

Title: Passing the button object to the OnClick method?
Post by: bodosaher on May 10, 2014, 08:11:34 AM
In previous NGUI versions I used to have a master script and when a button gets clicked it sends OnClick message to the script, I used something like this:
public void ButtonClicked(Gameobject g) {}
That used to work to determine which button got clicked but now with the new NGUI I cant use those parameters and instead I have to leave the parameters field empty "public void ButtonClicked() {}"
If I use the previous technique I get the error ArgumentException: Couldn't bind to method 'ButtonPressed'.
Any solutions?
Title: Re: Passing the button object to the OnClick method?
Post by: ArenMook on May 11, 2014, 12:26:55 AM
On Click notification set on the UIButton in inspector lets you choose any function, including functions that have parameters. If you choose a function with parameters, you can then set those parameters using any value you want, including passing the button's game object if you like.

However UIButton.current.gameObject already tells you that.