Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: lime-green.at on February 04, 2013, 08:20:22 AM

Title: UICheckbox event reciever function no reference to the checkbox
Post by: lime-green.at on February 04, 2013, 08:20:22 AM
Hey,

im currently implementing a scene with about 30 checkboxes, all checkboxes are managed by the same controller. Is there any way to send the name of the checkbox or some other reference with the method call at the event reciver? Its also kinda annoying the checkbox set's itself at Start with calling the controller method...

Regards
Title: Re: UICheckbox event reciever function no reference to the checkbox
Post by: ArenMook on February 04, 2013, 09:19:35 AM
UICheckbox.current
Title: Re: UICheckbox event reciever function no reference to the checkbox
Post by: lime-green.at on February 04, 2013, 11:35:23 AM
And how to send that information to the controller when calling the event function on the event handler?

Regards
Title: Re: UICheckbox event reciever function no reference to the checkbox
Post by: lime-green.at on February 04, 2013, 12:04:17 PM
Got it, i guess it would be cool if you would implement something like that in the next version of ngui :)


Event Reciver Class
  1.     public void OnStateChange(string[] info)
  2.     {
  3.         Debug.Log(info[0]);
  4.         Debug.Log(info[1]);
  5.     }

UICheckbox
  1.                         // Send out the event notification
  2.                         if (eventReceiver != null && !string.IsNullOrEmpty(functionName))
  3.                         {
  4.                                 current = this;
  5.                 string[] temp = new string[2];
  6.                 temp[0] = "" + mChecked;
  7.                 temp[1] = current.gameObject.name;
  8.  
  9.                 eventReceiver.SendMessage(functionName, temp, SendMessageOptions.DontRequireReceiver);
  10.                         }
Title: Re: UICheckbox event reciever function no reference to the checkbox
Post by: ArenMook on February 04, 2013, 07:36:19 PM
Huh? Why are you doing that?

In your callback function, UIChecked.current tells you the checkbox that triggered it (the checked one), which lets you do UIChecked.curent.name. There is no need to modify NGUI for this.
Title: Re: UICheckbox event reciever function no reference to the checkbox
Post by: lime-green.at on February 05, 2013, 03:15:38 AM
Ah cool, thanks. Didn't notice that's static :)

Regards