Hello Guest

Author Topic: Button's events  (Read 3645 times)

hromoydron

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Button's events
« on: June 29, 2013, 08:39:57 pm »
I make a script and attach it to button:
Code: [Select]
void OnClick()
{
     Debug.Log("tada");
}

but nothing happens, why?))

hromoydron

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Button's events
« Reply #1 on: June 29, 2013, 08:55:16 pm »
or I should do like this:
Code: [Select]
this.OnClick += ButtonClick;
but unity want definition for OnClick

?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Button's events
« Reply #2 on: June 29, 2013, 09:16:33 pm »
The UI system uses .net events. You should read up some basics about how that works. If you want an example of it set up, look in tk2dUIDemoController.cs - there are a few examples of buttons being used there.