Hello,
I’m brand new to Unity and I’m trying to figure out how to use NGUI to make menus for my game. The documentation says there’s an onClick() function for each button but I can’t find it. How do I execute code when my buttons are clicked?
Hello,
I’m brand new to Unity and I’m trying to figure out how to use NGUI to make menus for my game. The documentation says there’s an onClick() function for each button but I can’t find it. How do I execute code when my buttons are clicked?
Just create a function in the script that is attached to the button Game object. For example like this:
void OnClick ()
{
//Do stuff
}
That function will be called every time the button is pressed.
I wrote up a tutorial that just covers making a button in NGUI from scratch. As fffMalzbier said, you basically just need a script that does something in the OnClick () method, and the code inside is executed every time the button gets clicked.