The Unity3d has a built-in GUI,
First, use the GUI to implement a button, and click Implement Trigger,
void Ongui () {//gui. button (new Rect (10,10,50,50), "Nihaoa"), if (GUI. button (new Rect (), "button") {Debug.Log ("wo shi Yi ge an niu");}}
Here the screen will create a button, click on the button, the following sentence will appear:
Use of text input boxes:
Note that the assignment here will be assigned to itself, otherwise each frame will be displayed, the previous value is brushed off
Using unityengine;using System.collections;public class Getbutton:monobehaviour {//Use this for Initializationpublic Re CT rec; public string Text;void Start () { text = "Please enter";} Update is called once per framevoid Update () {}void Ongui () { text = GUI. TextField (New Rect (0, 0, +, +), text);}}
check box:
Using unityengine;using System.collections;public class Getbutton:monobehaviour {//Use the For initialization pub LIC bool Toogbalet = true; public bool Toogbalem = false;void Start () { }//update was called once per framevoid update () {}void Ongui () { to Ogbalet = GUI. Toggle (New Rect (0, 0, +,), Toogbalet, "Sport"); Toogbalem = GUI. Toggle (New Rect (), Toogbalem, "Art");}
You can implement, select and cancel the effects, each time you click, will refresh the Toogbalet value to determine the effect of the display:
Implementation of the progress bar:
Using unityengine;using System.collections;public class Getbutton:monobehaviour {//Use the For initialization pub Lic float hsliaervalue = 0f;void Start () { }//update is called once per framevoid update () {}void Ongui () { Hsli Aervalue = GUI. Horizontalslider (New Rect, Hsliaervalue, 0, 10);}}
:
Unity3d GUI Learning