Ngui, the button itself with the OnClick event, but Sprite,label (also tied with the widget) does not trigger the event, in fact Ngui event trigger must add box Collider, and tick is Trigger, To set the box size size in the inspector window, you can tick auto-adjust to match in the Widget's collider. There is also a more important parameter that needs to be set correctly, that is UI root under the camera parameter, in the inspector window, to determine the Event type in Uicamera select the 3D ui,event mask selection everything.
Then add a C # script script,
Using Unityengine;
Using System.Collections;
public class Spriteclicktest:monobehaviour {
Private Uispriteanimation spriteanimation;
void Start ()
{
Spriteanimation = getcomponent<uispriteanimation> ();
}
void OnClick ()
{
if (spriteanimation.isplaying) {
Pause Animation
Spriteanimation.stop ();
} else {
The animation plays back
Spriteanimation.reset ();
}
}
}
In the Inspector window
Click Run game, just set in the wizard script, will be the corresponding OnClick event.
Unity Plugin Ngui Learning (6)--about how widgets add trigger events