GUI Text 用户界面文本
GUI Text displays text of any font you import in screen coordinates.
GUI Text 在屏幕坐标中显示你导入的任何字体的文本。
The GUI Text Inspector
Please Note: Unity 2.0 introduced UnityGUI, a GUI Scripting system. You may prefer creating user interface elements with UnityGUI instead of GUI Texts. Read more about how to use UnityGUI in the GUI Scripting Guide.
请注意: Unity 2.0 引入UnityGUI,它是一个GUI脚本系统。您可能更愿意用 UnityGUI代替GUI Text来创建用户界面元素 。了解更多有关如何使用UnityGUI 在GUI脚本指南
Properties 属性
- Text 文本 The string to display. 要显示的字符串。
- Anchor 锚 The point at which the Text shares the position of the Transform.
文本上的哪个点共享此变换的位置。 - Alignment 对齐 How multiple lines are aligned within the GUIText.
GUIText如何多行对齐。 - Pixel Offset 像素偏移 Offset of the text relative to the position of the GUIText in the screen.
文本中的相对于GUIText在屏幕上的位置的偏移。 - Line Spacing 行距 How much space will be in-between lines of Text.
文本行之间的间距 - Tab Size 制表符大小 How much space will be inserted for a tab ('\t') character. As a multiplum of the space character offset.
多少空格将被插入一个选项卡("\t")字符。作为一个空格字符偏移量的倍数(德语multiplum 倍数)。 - Font 字体 The Font to use when rendering the text. 显示文本所用的字体
- Material 材质 Reference to the Material containing the characters to be drawn. If set, this property overrides the one in the Font asset.
关于包含被绘制字符的材质。如果设置了这个属性,会覆盖掉原来在字体资源。 - Pixel Correct 像素修正 If enabled, all Text characters will be drawn in the size of the imported font texture. If disabled, the characters will be resized based on the Transform's Scale.
如果启用,所有文本字符将以导入的字体纹理的大小来进行绘制。如果禁用,字符将被在变换规模的基础上进行调整
Details 详情
GUI Texts are used to print text onto the screen in 2D. The Camera has to have a GUI Layer attached in order to render the text. Cameras include a GUI Layer by default, so don't remove it if you want to display a GUI Text. GUI Texts are positioned using only the X and Y axes. Rather than being positioned in World Coordinates, GUI Texts are positioned in Screen Coordinates, where (0,0) is the bottom-left and (1,1) is the top-right corner of the screen
To import a font see the Font page.
GUI Text用于在2D屏幕上打印文字。相机必须有一个GUI层关联,用来显示文本。摄像机包括一个默认的GUI层,所以如果你想显示GUI文本,不要删除它。GUI文本只使用X和Y轴定位。。。而不是在世界坐标中的位置进行定位,GUI Text被放置在屏幕坐标,(0,0)是左下角。(1,1)是在屏幕右上角 。
要导入字体,见字体页。
Pixel Correct 像素修正
By default, GUI Texts are rendered with Pixel Correct enabled. This makes them look crisp and they will stay the same size in pixels independent of the screen resolution.
默认情况下,GUI文本会启用像素修正来显示的。这使得它们看起来干净利落的,他们将留在相同大小的像素,与屏幕的分辨率无关。
Hints 提示
- When entering text into the Text property, you can create a line break by holding Alt and pressing Return.
当在Text属性里输入文本,你可以通过按住Alt键,按回车键换行。 - If you are scripting the Text property, you can add line breaks by inserting the escape character "\n" in your strings.
如果你在脚本编辑Text属性,您可以通过插入转义字符"\ n"在你的字符串来换行。 - You can download free true type fonts from 1001freefonts.com (download the Windows fonts since they contain TrueType fonts).
您可以从1001freefonts.com 下载免费True Type字体。 (下载Windows的字体,因为它们包含TrueType字体)