Unity3d NGUI usage (2) (UILabel Chinese font and clickable font)

Source: Internet
Author: User

You can use Unity3d NGUI to create a font clickable effect and click the link to open the website.

There is also a Chinese font display, which can directly call the built-in font of the system, without the support of third-party Fonts


UILabel (Script parameter description)


The first font option, NGUI uses a static font. When we need to display Chinese characters, it is best to use a dynamic font, or we can also make a static font set.

Font Size: Font Size

Material: Specifies the font texture. If you need a color font

Text: display content

Overflow: Fill content options, 1, ShrinkContent (based on content) 2, ClampContent (based on fonts)

3. ResizeFreely (filling Based on the Content Level) 4. Filling Based on the Content height

Alignment: font Alignment

Keep crisp: Dynamic font sharpening

Gradient: font Gradient

Effect: font Effect

Spaceing: font Interval

Max Lines: How many Lines to display the font

BBCode: Use NGUI font customization to format the font


1. Create a Chinese font

A. Create a UILabel In the Widget Tool

B. Select NGUI as Unity in the inspector window of UILabel, and then select Font-Arial

C. Now we use a dynamic font that can display Chinese characters.


2. Create a link font

A. Add a Script to the UILabel of the click event to be added.

void OnClick (){UILabel lbl = GetComponent<UILabel>();if (lbl != null){string url = lbl.GetUrlAtPosition(UICamera.lastHit.point);if (!string.IsNullOrEmpty(url)) Application.OpenURL(url);}}

B. Add a Box Collider for the current UILabel and adjust the Box Collider size to the window size of the current UILabel.

Hook the Is Trigger option


C. Currently, NGUI supports three types of formatting fonts: 1 ([B] bold [/B] dynamically changing the font display effect) 2 ([u] underline [/u] adding underscores

[S] strikethrough [/s] strikethrough) 3 ([url = http://www.tasharen.com/?[u=clickable hyperlinks [/u] [/url] add website links)


Click clickable to display all formatting results.



Unity3d NGUI usage (2) (UILabel Chinese font and clickable font)


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.