The following uses label and sprite as examples to describe how to add an event Method for clicking a response to a control in ngui.
First, add the label control under uiroot, and then right-click label --> attach --> box Collider in the scene scenario, indicating that the label has added collision detection.
Right-click label --> attach --> button script. and add the uibutton script.
The method for adding the collision tool and script to Sprite is the same as label.
Then create a Sprite, add a child label, and add the collision tool and script.
Create a C # script and assign it to an empty object (gameobject) or any other object.
The script content is:
Public Class Click: monobehaviour { Public Void Onlableclick () {print ( " Clicked lable " );} Public Void Onspriteclick () {print ( " Clicked Sprite " );} Public Void Onclick () {print ( " Clicked " );}}
Finally, pull the script object to the policy attribute of on click.
Click the corresponding tag.
Use ngui for button-like operations