Unity3d GUI Learning

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.