GUI create each common control (i)

Source: Internet
Author: User

First, make a statement:

1, this is a wild way non-training small rookie of the study, so sincerely welcome criticism (and the content may be wrong);

2, I currently use the Unity3d version is 5.3.5;

Anyway

In fact, it's very rare to create UI controls with the GUI in the development process! (since Unity4.6 began, unity has its own visual Ugui)

However, as a companion to Unity for so many years, but also for the occasional "system learning" These four words, the rookie decided to spend 2--3 a space to

A little recap of the knowledge points about the GUI. gossip Less, on dry goods!!

1. Create button (single):
In the Void Ongui () method:
Gui. button (new Rect (SCREEN.WIDTH/10,SCREEN.HEIGHT/2,SCREEN.WIDTH/5,SCREEN.HEIGHT/10), "button");//position, size, content (you can also set the style);

Draw a button from the layout manager: Guilayout.button (New Guicontent ("Play Game", "Button1"));

2. Create a Label:
In the Void Ongui () method:
Gui. Label (New Rect (SCREEN.WIDTH/10, SCREEN.HEIGHT/10, SCREEN.WIDTH/5, SCREEN.HEIGHT/10), "Hellow world!"); /location, size, content (you can also set style);

3, create box, TextField, Toggle (switch (BOOL)) are similar;

/*************************************************************/************************************************ *****/


skin/color/tooltip/changed/backgroundcolor/contentcolor/enabled/depth:
These are the variables of the graphical user component that are used to set up the graphical UI components as a whole


4. Set the background color, component color, and text color in the component (composited with component color) in void Ongui () method
The methods were: Gui.backgroundcolor = Color.yellow; Gui.color = Color.green;
Gui.contentcolor = color.red;

5, there are other methods (time can be specifically checked)
Changed/enabled (all bool types).
Gui.changed: Used to detect whether the data of my input control has changed;
Gui.enabled: Used to control and determine the activation of the graphical user interface (only for the controls underneath the statement).


6. ToolTip Usage (cue box variable) Example:
Draw a button named Click me and set the prompt message for this is the ToolTip;
Gui. button (new Rect (SCREEN.WIDTH/2, SCREEN.HEIGHT/10, SCREEN.WIDTH/5, SCREEN.HEIGHT/10), New Guicontent ("Click Me", "T He is the Tooltip "));
Draw a label lable and assign the hint message "This is the ToolTip" to the label
Gui. Label (New Rect (SCREEN.WIDTH/2, SCREEN.HEIGHT/5, SCREEN.WIDTH/5, SCREEN.HEIGHT/10), Gui.tooltip);

7. Depth variable
The behavior of sorting the controls in the current graphical user interface in depth;

All right! As a result of the actual development has been rarely used, so the GUI-related knowledge of a rough mention, interested in small partners can private messages to me, specific study together!

"Welcome to Reprint"

Reprint please indicate source: le study

GUI create each common control (i)

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.