C # Write the basic GUI of unity-2

Source: Internet
Author: User

1. text input box

1 Public String text; 2 3 void ongui () {4 text = GUI. textfield (New rect (140,140,100, 40), text); 5 6 if (GUI. button (New rect (10, 10,100, 50), text) 7 {8 print ("the user clicked the button"); 9} 10}

Effect:

 

2. switch button control

1 public bool toggleBool;2 3     void OnGUI(){4         toggleBool = GUI.Toggle(new Rect(10, 10, 100, 30), toggleBool, "Toggle");5     }

Effect:

3. Horizontal Slider

1 void Update () {2         print(hSliderValue);3     }4 5     private float hSliderValue=0.0F;6     void OnGUI(){7         hSliderValue = GUI.HorizontalSlider(new Rect(10, 10, 100, 30), hSliderValue, 0, 10);8     }

Effect:

 

4. Vertical Slide, similar to horizontal slide

 

C # Write the basic GUI of unity-2

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.