Gui Control Learning 1 (C #)

Source: Internet
Author: User

Code snippet:

Using unityengine; using system. collections; public class skintest: monobehaviour {public texture imgbtn; private string textcontent = "textfield"; private string passwordtoedit = "passwordfield "; private string textareatoedit = "Hello world \ n I'm textarea"; Public texture toggleimgtexture; private bool toggletxt; private bool toggleimg; private int toolint = 0; private string [] toolnamearr = {"toolbar1", "toolbar2", "toolbar3"}; private float hslidevalue = 0; private float vslidevalue = 0; private float hsbarvalue; private float vsbarvalue; private vector2 scrollposition = vector2.zero; private rect windowbox = new rect (400,250,220,100); // use this for initialization void start () {}// update is called once per frame void Update () {} void ongui () {// label control GUI. label (New rect (10, 10,), "label"); // button control if (GUI. button (New rect (,), "button") {print ("press the button. ");} If (imgbtn) {If (GUI. button (New rect (10, 60, imgbtn. width, imgbtn. height), imgbtn) {print ("push button. ") ;}} // repeatbutton control if (GUI. repeatbutton (New rect (10,130,100, 20), "repeatbutton") {print ("Press repeatbutton. ");} // textfield control textcontent = GUI. textfield (New rect (10,160,120, 20), textcontent); // passwordfield control passwordtoedit = GUI. passwordfield (New rect (10,190,120, 20), passwordtoedit, "*" [0], 25); // textarea control textareatoedit = GUI. textarea (New rect (10,220,120,100), textareatoedit); // toggle control toggletxt = GUI. toggle (New rect (10,350,100, 20), toggletxt, "toggle text"); If (toggleimgtexture) {toggleimg = GUI. toggle (New rect (10,380, 50, 50), toggleimg, toggleimgtexture);} // Toolbar Control toolint = GUI. toolbar (New rect (10,430,200, 30), toolint, toolnamearr); // slide control hslidevalue = GUI. horizontalslider (New rect (,), hslidevalue,); vslidevalue = GUI. verticalslider (New rect (30,100,), vslidevalue,); // scrollbar control hsbarvalue = GUI. horizontalscrollbar (New rect (220,160,100, 30), hsbarvalue, 10); vsbarvalue = GUI. verticalscrollbar (New rect (220,200, 30,100), vsbarvalue, 10); // scrollview control scrollposition = GUI. beginscrollview (New rect (records, 40, 200,200), scrollposition, new rect (550,650,); GUI. button (New rect (,), "top-left"); GUI. button (New rect (,), "Top-Right"); GUI. button (New rect (420,630,100, 20), "bottom-left"); GUI. button (New rect (680,630,100, 20), "bottom-Right"); GUI. endscrollview (); // end the rolling view // window windowbox = GUI. window (0, windowbox, windowfun, "my window");} void windowfun (INT windowid) {GUI. button (New rect (60,50, 100,20), "window button"); GUI. dragwindow (New rect ));}}

Effect

 

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.