A game about forced loneliness, made by TACStudios
1# Rich Text 2 3Rich text tags alter the appearance and layout of text by supplementing or overriding TextMesh Pro GameObject properties. For example, you can use rich text tags to change the color or alignment of some, or all of your text without modifying its properties or material. 4 5**To use rich text tags:** 6* Enter any [supported rich text tags](RichTextSupportedTags.md) in the TextMeshPro [**Text** input field](TMPObjectUIText.md#text), inline with the text you want to display. 7 8**To disable rich text for a TextMesh Pro object:** 9* Open the TextMesh Pro GameObject in the Inspector, and disable the **Text Mesh Pro > Extra Settings > Rich Text** property. 10 11## Rich Text Tags 12 13Rich text tags are similar to HTML or XML tags, but have less strict syntax. 14 15A simple tag consists of only the tag name, and looks like this: 16 17`<tag>` 18 19For example, the `<b>` tag makes text bold, while the `<u>` tag underlines it. 20 21### Tag attributes and values 22 23Some tags have additional values or attributes, and look like this: 24 25 `<tag="value">` or `<tag attribute="value">` 26 27For example `<color=”red”>` makes text red. `Red` is the `color` tag’s value. 28 29 Similarly `<sprite index=3>` inserts the fourth sprite from the default Sprite Asset. `index` is an attribute of the `sprite` tag, and its value is `3`. 30 31A tag, including its attributes, can be up to 128 characters long. 32 33The table below lists possible attribute/value types. 34 35|Attribute/value type:|Example| 36|-------------|-------------| 37|Decimals|`0.5`| 38|Percentages|`25%`| 39|Pixel values|`5px`| 40|Font units|`1.5em`| 41|Hex color values|`#FFFFFF` (RGB)<br/>`#FFFFFFFF` (RGBA)<br/>`#FF` (A)| 42|Names|Both `<link=”ID”>` and `<link=ID>` are valid.| 43 44## Tag scope and nested tags 45 46Tags have a scope that defines how much of the text they affect. Most of the time, a tag added to a given point in the text affects all of the text from that point forward. 47 48For example, adding the tag `<color="red">` at the beginning of the text affects the entire text block: 49 50`<color="red">This text is red` 51 52![Example image](../images/TMP_RichTextExample1.png)<br/> 53_Successive color tags_ 54 55Adding the same tag in the middle of the text block affects only the text between the tag and the end of the block : 56 57`This text turns<color="red"> red` 58 59![Example image](../images/TMP_RichTextExample2.png)<br/> 60_Successive color tags_ 61 62If you use the same tag more than once in a text block, the last tag supersedes all previous tags of the same type. 63 64`<color="red">This text goes from red<color="green"> to green` 65 66![Example image](../images/TMP_RichTextExample3.png)<br/> 67_Successive color tags_ 68 69You can also limit the scope of most tags using a closing tag. Closing tags contain only a forward slash and the tag name, like this: `</tag>` 70 71Tags can also be _nested_ so one tag’s scope is within another tag’s scope. For example: 72 73``` 74<color=red>This text is <color=green>mostly </color>red. 75``` 76 77![Example image](../images/TMP_RichTextExample4.png)<br/> 78_Successive color tags_ 79 80The first `<color>` tag’s scope is the entire text block. The the second `<color>` tag has a closing tag that limits its scope to one word. 81 82When you nest tags, you don't have to close their scopes in the same order that you started them. 83 84## Rich-text tags and right-to-left text 85 86TextMesh Pro's right-to-left editor does not distinguish between regular text and rich text tags. Rich text tags that you enter in the right-to-left editor do not work unless you type them right-to-left as well. 87 88The easiest way to apply rich text tags to right-to-left text is to type the text in the right-to-left editor, and then apply the tags in the regular editor.