UNITY3D_GUI_2__ (Study of the energy bar)

Source: Internet
Author: User
Tags float number

This is a bit of a leap from the previous article, but the GUI has official documents, but also can view the editor's own script document, more look at the API, multi-operation operation, certainly can be skilled. So this article I introduce a little bit of skill, the big guy skipped this article, not suitable for the big guy, will be your education.

1, the first must be open Unity editor.

2. Then add the C # script to the script folder, and I added the skill_01 script. (To set the folder yourself, easy to manage, otherwise the file is not easy to manage the chaos)

3, note that the name of the script once determined not to change, because the name of a script is a class name, changes will be prone to the program is incorrect.

4, then of course, open the script to enter the following code.

Using System.Collections;
Using System.Collections.Generic;
Using Unityengine;

public class Skill_01:monobehaviour {
public float number = 1.0f;
private void Ongui ()
{
Gui. BeginGroup (New Rect (0,0,256,32)); Set the first grouping
Gui. Box (new Rect (0, 0, 256, 32), ""); The intermediate parameters can be viewed with hints,
Each method of overloading is quite a lot of, can not go to one by one realize it. Excuse me.
Gui. BeginGroup (New Rect (0, 0, 256*number, 32)); Set up a second grouping
Gui. Box (new Rect (0, 0, 256, 32), "");
Gui. Endgroup ();
Gui. Endgroup ();//Two end-grouped statements
}
}

5, run the program, you can move the number in the Code Properties window, to show the energy reduction and increase.

6, the game window display:

7, this is not the use of background pictures, there are resources can use the background picture, will be more realistic oh.

Conclusion: To go to class, more hasty, first withdrew, there are deficiencies in the hope that we can put forward criticism.

UNITY3D_GUI_2__ (Study of the energy bar)

Related Article

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.