Unity TextMesh Pro标记

193 阅读1分钟

携手创作,共同成长!这是我参与「掘金日新计划 · 8 月更文挑战」的第7天,点击查看活动详情

1、Color

(1)<color=yellow>Yellow</color>
(2)<#00ff00>Green

图片.png

(3)透明度:<alpha=#CC> <alpha=#30>

2、Style

2.1 粗体(Blod)

<b>Bold</b>

2.2 斜体(Italics)

<i>Italics</i>

图片.png

3、Line

3.2 下划线(Underline)

<u>Underline</u>

3.2 删除线(Strikethrough)

<s>Strikethrough</s>

图片.png

4\Superscript and Subscript

4.1 上标(Sup)

Superscript - X<sup>3</sup>

4.2 下标(Sub)

Subscript - v<sub>x</sub>

5、标记(Highlighting)

<mark=#00000060>Highlighting</mark>

颜色为8位,支持a通道。

图片.png

6、大小写

6.1 all caps

<allcaps>all caps</allcaps>

6.2 small caps

The <smallcaps>small caps</smallcaps>

6.3 upper case

<uppercase>upper case</uppercase>

6.4 lower case

<lowercase>LOWER CASE</lowercase>

图片.png

7、字间距(Character spacing)

<cspace=0.3em>Character spacing</cspace>

em是一个相对单位

图片.png

8、等宽字(Mono spaced)

<mspace=1em>Character spacing</cspace>

图片.png

9、行高 line height

<line-height=75>line height<line-height=75>

图片.png 图片.png

10、nobr(不换行)

<nobr>No Line-Break</nobr>

图片.png 图片.png

11、Size

<size=20>Size 20</size>
<size=80%>Size 80%</size>
<size=1.2em>Size 1.2em</size>

图片.png 图片.png

12、图文混排

<sprite="DropCap Numbers" index=11>

13、缩进、偏移

缩进: <indent=3em>indent</indent>
偏移:<pos=110>

14、布局

居中:<align=center>center</align>
居左:<align=center>left</align>
居右:<align=right>right</align>
两端对齐尾行居左:<align=justified>justified</align>
两端对齐:<align=flush>flush</align>

15、超链接

<link="linkID">link</link>

C#代码:

public class Test : MonoBehaviour, IPointerClickHandler
{
    private TextMeshProUGUI textMeshPro;

    private void Start()
    {
        textMeshPro = GetComponent<TextMeshProUGUI>();
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        Vector3 pos = new Vector3(eventData.position.x, eventData.position.y, 0);
        int linkIndex = TMP_TextUtilities.FindIntersectingLink(textMeshPro, pos, null); //uicamra
        if (linkIndex > -1)
        {
            TMP_LinkInfo linkInfo = textMeshPro.textInfo.linkInfo[linkIndex];
            Debug.Log(linkInfo.GetLinkID());
        }
    }
}