Tasharen Entertainment Forum

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:

  1. public enum SortType {t1,t2...t20}
  2. public Class Controller {
  3.     public void sort(SortType t);
  4. }
  5.  

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:
  1. class SortButton : Monobehavior {
  2.     public SortType type;
  3.     public Controller controller;
  4.     void OnClick() {controller.sort(type)}
  5. }
  6.  
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 :)