Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: aikitect on December 27, 2013, 11:41:52 AM

Title: How do I send an event to another object using the new EventDelegate system?
Post by: aikitect on December 27, 2013, 11:41:52 AM
In NGUI <2.7, I was able to set an eventReceiver for UICheckbox to send an event to another object within my scene.

For example, I have the code:

  1. checkbox.eventReceiver = GameObject.FindWithTag("Model")
  2.  

How do I do this with the new EventDelegate model in NGUI 3?
Title: Re: How do I send an event to another object using the new EventDelegate system?
Post by: ArenMook on December 27, 2013, 03:59:58 PM
EventDelegate.Add(checkbox.onChange, YourFunction);
Title: Re: How do I send an event to another object using the new EventDelegate system?
Post by: aikitect on January 25, 2014, 01:56:04 PM
So what exactly goes into "YourFunction"?  So for example, my GameObject is called "Model", and the script that is attached is "Controller", and the function within "Controller" that I want to call is "UpdatePoints".
Title: Re: How do I send an event to another object using the new EventDelegate system?
Post by: ArenMook on January 25, 2014, 03:59:44 PM
  1. EventDelegate.Add(checkbox.onChange, UpdatePoints);
  1. void UpdatePoints ()
  2. {
  3.     Debug.Log(UIToggle.current.name + " state: " + UIToggle.current.value);
  4. }