Unity2017.1 official Ugui document translation--rich Text

Source: Internet
Author: User
Tags tag name

Rich Text

The text for UI elements and text meshes can incorporate multiple font styles and sizes. Rich text is supported both for the UI system and the Legacy GUI system. The text, Guistyle, Guitext and Textmesh classes has a Rich Text setting which instructs Unity to look for markup tags WI Thin the text. The Debug.Log function can also use these markup tags to enhance error reports from code. The tags is not a displayed but indicate style changes to being applied to the text.

The text of UI elements and text grids can contain multiple font styles and sizes. Rich text supports both UI systems and traditional GUI systems. The Text,guistyle,guitext and Textmesh classes have rich text settings that instruct unity to look for tag tags within the text. The Debug.Log function can also use these tag tags to enhance error reporting in your code (such as red). The label does not appear, but it indicates the style change that will be applied to the text.

Markup format

Tag format

The markup system is inspired by HTML, but isn ' t intended to being strictly compatible with standard HTML. The basic idea is, a section of text, can be enclosed inside a pair of matching tags:-

The tagging system is inspired by HTML, but is not intended to be strictly compatible with standard HTML. The basic idea is that you can include a piece of text in a pair of matching tags:

We are <b>not</b> amused

As the example shows, the tags are just pieces of text inside the "angle bracket" characters, < and;. The text inside the tag denotes its name (which in this case is just B). Note that the tags at the end of the section have the same name as the one at the start, but with the Slash/character added . The tags is not displayed to the user directly but is interpreted as instructions for styling the text they enclose. The b tag used in the example above applies boldface to the word ' not ', so the text would appear onscreen as:-

As the example shows, the label is just a text fragment in the "angle brackets" character < and >. The text within the tag indicates its name (in this case, B). Note that the label at the end of the paragraph is the same as the start tag name, but the slash/character is added. These tags are not displayed directly to the user, but are interpreted as a style that guides the text they include. The b tag used in the previous example applies the bold word to the word "not", so the text will appear on the screen as:

We is not amused

A marked up section of text (including the "tags that enclose it") is referred to as an element.

A piece of text that is marked (including the outer label) is called an element.

Nested elements

Nested elements

It is possible-to-apply more than one style to a sections of text by "nesting" one element inside another

You can apply multiple styles to a piece of text by "nesting" one element into another

We are <b><i>definitely not</i></b> amused

The I tag applies italic style, so this would is presented onscreen as

The I tag applies italic style, so the screen will display

We is definitely not amused

Note the ordering of the ending tags, which is on reverse to that of the starting tags. The reason for it perhaps clearer when you consider the inner tags need not span the whole text of the outermost Element

Note the order of the end labels, as opposed to the start label order. The reason for this is to help you more clearly consider that the inner label does not have to span the outermost element of the entire text. (Labels cannot be cross-contained, only a pair of labels can contain another pair; a pair of labels cannot contain only part of another pair of tags.) )

We are <b>absolutely <i>definitely</i> not</b> amused

which gives

Shown as:

We is absolutely definitely not amused

Tag parameters

Label parameters

Some tags has a simple all-or-nothing effect on the text and others might allow for variations. For example, the color tag needs to know which color to apply. Information like the "added to tags by" the use of parameters:-

There are some labels that are simple with or without effects, but others are allowed to change. For example, a color label needs to know which color to apply. Information like this is added to the label by using parameters:

We is <color=green>green</color> with envy

Note that the ending tag doesn ' t include the parameter value. Optionally, the value can be surrounded by quotation marks and this isn ' t required.

Note that the end tag does not contain a parameter value. Optionally, the parameter value values can be enclosed in quotation marks, but this is not required.

Supported tags

Supported tags

The following list describes all of the styling tags supported by Unity.

The following list describes all the tag styles supported by unity.

B

Renders the text in boldface.

Display text in bold

We are <b>not</b> amused.

I

Renders the text in italics.

Display text in italics

We is <i>usually</i> not amused.

Size

Sets the size of the text according to the parameter value, given in pixels.

Sets the size of the text, in pixels, based on the parameter value.

We are <size=50>largely</size> unaffected.

Although this tag was available for Debug.Log, you'll find that the line spacing in the window bar and Console looks stra Nge If the size is set too large.

Although this label is available for Debug.Log, if the size is set too large, you will find that the line spacing in the window bar and console looks strange.

Color

Sets the color of the text according to the parameter value. The color can is specified in the traditional HTML format. #rrggbbaa ... where the letters correspond to pairs of hexadecimal digits denoting the red, green, blue and alpha (transparency) values for the color. For example, cyan @ Full opacity would is specified by

Sets the color of the text based on the parameter value. Colors can be specified in the traditional HTML format. #rrggbbaa ... Each pair of letters represents the hexadecimal digits of the color's red, green, blue, and alpha (transparency) values. For example, the full opacity of cyan can be expressed in this way

<color= #00ffffff ...

Another option is to use the name of the color. This was easier to understand but naturally, the range of colors are limited and full opacity are always assumed.

<color=cyan>, .....

The available color names is given in the table below.

Another option is to use the name of the color. This is easy to understand, but naturally, the range of colors is limited and is always assumed to be completely opaque.

<color = cyan> ...

The available color names are given in the table below (this is not translated, see the original).

Material

This was only useful for text meshes and renders a sections of text with a material specified by the parameter. The value is a index into the text mesh ' s array of materials as shown by the Inspector.

This is only useful for text grids and renders a piece of text with the material specified by the parameter. The value is the index of the text grid material array displayed by Inspector.

We are <material=2>texturally</material> amused

Quad

This is a useful for text meshes and renders a image inline with the text. It takes parameters that specify the material to use for the image, the image height in pixels, and a further four that de Note A rectangular area of the image to display. Unlike the other tags, Quad does not surround a piece of text and so there are no ending tag-the slash character is place D at the end of the initial tag to indicate that it is "self-closing".

This is used only for text grids to render pictures in text. It needs to specify the parameters of the material to be used for the picture, the height of the picture in pixels, and the other four parameters that represent the rectangular area of the picture to be displayed. Unlike other labels, Quad does not surround a piece of text, so there is no end tag-the slash character is placed at the end of the original label to indicate that it is "closed by itself".

<quad material=1 size=20 x=0.1 y=0.1 width=0.5 height=0.5/>

This selects the material at position in the renderer's material array and sets the height of the image to the pixels. The rectangular area of image starts at given by the X, Y, Width and height values, which is all given as a fraction of t He unscaled width and height of the texture.

This selects the material for the position in the render equipment prime number group and sets the height of the picture to 20 pixels. The rectangular area of the picture starts with X, Y, width, and height values, which are given by the texture's non-scaling and height.

Editor GUI

Editor GUI

Rich text is disabled by default in the editor GUI system and it can be enabled explicitly using a custom guistyle. The RichText property should is set to true and the style passed to the GUI function in question:-

In the editor GUI system, Rich text is disabled by default, but can be explicitly enabled using custom Guistyle. The RichText property should be set to true and the style is passed in when the GUI function is called:

GUIStyle style = new GUIStyle ();style.richText = true;GUILayout.Label("<size=30>Some <color=yellow>RICH</color> text</size>",style);

Unity2017.1 official Ugui document translation--rich Text

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.