Author Topic: How do I send an event to another object using the new EventDelegate system?  (Read 2178 times)

aikitect

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 27
    • View Profile
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?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
EventDelegate.Add(checkbox.onChange, YourFunction);

aikitect

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 27
    • View Profile
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".

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
  1. EventDelegate.Add(checkbox.onChange, UpdatePoints);
  1. void UpdatePoints ()
  2. {
  3.     Debug.Log(UIToggle.current.name + " state: " + UIToggle.current.value);
  4. }