Unity3D development: graphic user interface class G.U. I

Source: Internet
Author: User

Next we will make two G.U. I instances in Unity3D to illustrate its usage. We create a shell launch game based on the existing scenarios. Think about what elements are required for a shell-fired game scene? Should I display shells in a corner of the screen? As in most 3D games, your magic value takes some time to reply after use. Next, we will create an ammunition filling effect.

Step 1: Make an ammunition filling pattern.

Use PhotoShop to create the ammunition filling time graph and save all of them as PNG files to the "Assets" resource] folder of the project. The ammunition filling Figure 9.1 shows:

Fig 9.1

Step 2: import a pattern.

Go back to the Unity3D software environment. For ease of classification, right-click the Project file bar --> "Create" --> "Folder" to Create a Folder, press F2 to change it to "Upload time", and then drag the imported five images into the folder. 9.2:

Fig 9.2
Step 3: Create an icon.
On the menu bar, select --> to create a G.U. I icon. This is a default Unity3D icon displayed on the Scene scenario panel, as shown in Figure 9.3:


Fig 9.3
In the Hierarchy list bar, select it and go to its attribute panel. Click the icon next to Texture to change it to the ammunition filling icon we just imported. The final display size and position of the icon are displayed by modifying other attribute values in the property panel, as shown in Figure 9.4:

Fig 9.4
Step 4: Create a text description.
On the menu bar, select --> to create a description of G.U. I text next to the icon. Its text input, text size, and text style are also adjusted in its property panel. 9.5:

Fig 9.5

Enable Unity3D to support Chinese Fonts

In the previous chapter, we learned how to use G.U. I graphics and text. However, a careful friend may find that Inputting Chinese in "GUI Text" has no effect. This is because Unity3D does not support Chinese characters. However, this does not affect the development of Chinese works. In Unity3D, you can assign any font as a material file to "GUI Text", which includes Chinese fonts.
The procedure is as follows:
Step 1: copy the required Chinese font to the "Assets" resource] folder in the project file.
Step 2: select --> in the menu bar to create a G.U. I text, click "Font" next to it in its property panel, and give its Font type to the Font you just copied, then, in the attribute panel, find the Text box next to "Text" and enter the Chinese content you want to enter. Observe the scene panel and get the result 10.1:

Fig 10.1

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.