Author Topic: add function on button at runtime  (Read 1904 times)

abhaya.agrawal

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 11
    • View Profile
add function on button at runtime
« on: July 10, 2015, 10:07:22 AM »
I want to add function at runtime on UiButton which is in another script

gameObject.GetComponent<UIButton>().onClick.Add(new EventDelegate(another_script_obj, "Call_Ui_Check_Collision()"));

its not working.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: add function on button at runtime
« Reply #1 on: July 12, 2015, 07:55:56 PM »
Get rid of "()" and use EventDelegate.Add, not onClick.Add.