Support => NGUI 3 Support => Topic started by: maxtangli on July 01, 2014, 09:40:18 PM
Title: UIButton inspector onClick not support function with basic type param?
Post by: maxtangli on July 01, 2014, 09:40:18 PM
Suppose I have a Controller class to sort a datalist:
publicenum SortType {t1,t2...t20}
publicClass Controller {
publicvoid sort(SortType t);
}
then I have 20 buttons to call sort. It would be convenient by using UIButton inspector to set callback function and param, but when I select sort method, the appeared arg0 turn to type of Object.
So what would be the best practice to use UIButon for this case?
I know I could attach a script for each button, but it still need extra code:
class SortButton : Monobehavior {
public SortType type;
public Controller controller;
void OnClick(){controller.sort(type)}
}
Title: Re: UIButton inspector onClick not support function with basic type param?
Post by: ArenMook on July 02, 2014, 05:31:28 AM
You currently can't pass static values into the callback functions -- only dynamically linked properties. Ability to specify static parameters is a planned feature. I suggest going with the second approach for now.
Title: Re: UIButton inspector onClick not support function with basic type param?
Post by: maxtangli on July 03, 2014, 03:19:52 AM
Thanks for your answer. Anticipate the coming of that feature :)