The button is the most commonly used UI node and contains components that have
1.Image components
Display the button's texture, drag the image map into the image component, and then click Set Native size to show the map's original size
2.Button components
Interatable: A tick indicates that a button can be clicked and interacted with, and a cancel hook indicates that it cannot be clicked and interacted with.
Transition: Over effect, A. Default state B. Mouse over effect highlighted sprite C. button press effect pressed Sprite D. button disable state disabled sprite
There are four values to choose from, none: Indicates no effect, color tint represents the effect of colour transform implementation, Sprite swap represents the effect of texture transformation, animation represents animation transform implementation effect.
To use the sprite swap type, drag the texture map into the corresponding highlighted sprite,pressed sprite,disabled sprite.
On Click () event Mount:
(1) First write an event script to mount the canvas node above.
(2) The source code of the event script, where On_button_click () is a bit like an event listener.
usingUnityengine;usingSystem.Collections;usingUnityengine.ui; Public classGame_scene:monobehaviour {//Use this for initialization voidStart () { } //when we want to bind the function to the editor's visible. //Public -Modified Public voidOn_button_click () {Debug.Log ("On_button_click called!!!!"); } //Update is called once per frame voidUpdate () {}}
(3) In the button node's on click () property, click "+" to add the event response object as canvas, the response function is On_button_click ().
(4) When you click on the button, the console will output. If you mount a duplicate two event listener, it will output two times.
Property changes:
(1) Change some properties of the button component in your code, such as set to Disabled.
void Start () { this. Transform. Find ("button"). Getcomponent<button>(); false ; }
About the button node in the UI in Unity