__GUI Text(GUI 文本)__在屏幕坐标中显示导入的任何字体的文本。
请注意:该组件涉及将 UI 纹理和图像绘制到屏幕的传统方法。您应改用 Unity 的最新 UI 系统。此外,这与 IMGUI 系统无关。
属性: | 功能: | |
---|---|---|
Text | 要显示的字符串。 | |
Anchor | Text 共享 Transform 位置的点。 | |
Alignment | GUIText 内的多行对齐方式。 | |
Pixel Offset | 文本在屏幕中相对于 GUIText 位置的偏移。 | |
Line Spacing | Text 的行间距。 | |
Tab Size | 为制表符 (‘\t’) 字符插入的空格数。作为空格字符偏移的倍数。 | |
Font | 渲染文本时使用的字体。 | |
Material | 引用包含要绘制的字符的__材质。如果设置此属性,将覆盖字符资源中的值。 | |Font Size__ | 要使用的字体大小。设置为 0 将使用默认字体大小。仅适用于动态字体。 |
Font Style | 要使用的字形,包括正常 (Normal)、粗体 (Bold)、斜体 (Italic) 或粗斜体 (Bold and Italic)。仅适用于动态字体。 | |
Pixel Correct | 如果启用此选项,则所有 Text 字符将以导入的字体纹理的大小绘制。如果禁用此选项,字符将根据 Transform 的 Scale 调整大小。 | |
Rich Text | 如果启用此选项,则允许使用 HTML 样式的标签进行文本格式设置。 |
GUI 文本用于在 2D 模式下将文本打印到屏幕上。摄像机__必须连接 GUI 层才能渲染文本。摄像机在默认情况下包含 GUI 层,因此如果要显示 GUI 文本,请不要将其删除。GUI 文本仅使用 X 和 Y 轴定位。GUI 文本不位于世界坐标中,而是位于屏幕坐标中,其中 (0,0) 表示屏幕的左下角,(1,1) 表示右上角。要在 Unity 5.0 中添加 GUIText 组件,应首先使用 GameObject > Create Empty__ 创建一个空的游戏对象,然后使用 Component > Rendering > GUIText 选项将 GUIText 组件添加到新创建的游戏对象。如果按 Play 时文本不可见,请检查变换组件是否具有合适的位置,通常为 (0.5, 0.5, 0.0)。
要导入字体,请参阅字体页面。
要使用富文本 (Rich Text),请参阅富文本页面。
默认情况下,GUI 文本在启用 Pixel Correct 的情况下渲染。因此,文本看起来很清晰,且无论屏幕分辨率如何,它们都将保持相同的像素大小。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.