Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
TextMesh
继承: PrimitiveMesh < Mesh < Resource < RefCounted < Object
根据文本生成 PrimitiveMesh。
描述
根据文本生成 PrimitiveMesh。
使用了矢量字形轮廓的动态字体才能用于生成 TextMesh。不支持位图字体(包括 TrueType/OpenType 容器中的位图数据,例如彩色 Emoji 字体)。
UV 布局由 4 个横条组成,从上到下依次为:正面占 40% 高度,背面占 40% 的高度,外面占 10% 的高度,内侧面占 10% 的高度。
教程
属性
|
||
|
||
|
||
|
||
|
||
BitField[JustificationFlag] |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
属性说明
AutowrapMode autowrap_mode = 0 🔗
void set_autowrap_mode(value: AutowrapMode)
AutowrapMode get_autowrap_mode()
如果设置为 TextServer.AUTOWRAP_OFF 以外的值,则文本将在节点的边界矩形内自动换行。如果你调整节点大小,就会自动更改其高度,从而显示所有文本。
用于近似贝塞尔曲线的步长(单位为像素)。值越小,曲线越平滑,但生成和渲染速度越慢。请根据字体大小和典型的观看距离进行调整。
注意:更改该属性会重新生成网格,这是一个耗时的操作,尤其是在字体较大和文本较长时。
生成的网格的深度,设为 0.0 时只有正面,此时的 UV 布局会变为让正面占据整张纹理。
用于显示文本的字体配置。
TextMesh 文本的字体大小。该属性与 pixel_size 协同工作。无论 curve_step 和 pixel_size 的值如何,更高的值都会产生更精细的字体。为了获得良好的性能,请考虑将该值保持在 63(含)以下,并根据需要调整 pixel_size 以放大文本。
注意:更改该属性会重新生成网格,这是一个耗时的操作,尤其是在字体较大且文本较长时。要高效地实时更改文本大小,请改为更改节点的 Node3D.scale。
HorizontalAlignment horizontal_alignment = 1 🔗
void set_horizontal_alignment(value: HorizontalAlignment)
HorizontalAlignment get_horizontal_alignment()
控制文本的水平对齐方式。支持左对齐、居中对齐、右对齐、填充(即两端对齐)。
BitField[JustificationFlag] justification_flags = 163 🔗
void set_justification_flags(value: BitField[JustificationFlag])
BitField[JustificationFlag] get_justification_flags()
行填充对齐规则。
用于断行和文本塑形算法的语言代码。如果留空,则使用当前区域设置。
行与行之间的额外纵向留白(单位为像素),留白会被添加到行的降部。该值可以为负数。
Vector2 offset = Vector2(0, 0) 🔗
文本绘制偏移量(单位为像素)。
注意:更改该属性会重新生成网格,这是一个耗时的操作。要高效地实时更改文本位置,请改为更改节点的 Node3D.position。
用于缩放文本在 3D 空间中单个像素宽度的大小。该属性与 font_size 协同工作。
注意:更改该属性会重新生成网格,这是一个耗时的操作,尤其是在字体大小较大且文本较长时。要高效地实时更改文本大小,请改为更改节点的 Node3D.scale。
StructuredTextParser structured_text_bidi_override = 0 🔗
void set_structured_text_bidi_override(value: StructuredTextParser)
StructuredTextParser get_structured_text_bidi_override()
为结构化文本设置 BiDi 算法覆盖。
Array structured_text_bidi_override_options = [] 🔗
void set_structured_text_bidi_override_options(value: Array)
Array get_structured_text_bidi_override_options()
设置 BiDi 覆盖的附加选项。
要从中生成网格的文本。
注意:由于是 Resource,所以它并不遵循 Node.auto_translate_mode 的规则。如果需要禁用翻译,则应使用 Object.set_message_translation() 手动完成。
Direction text_direction = 0 🔗
基础文本书写方向。
如果为 true,所有文本都将显示为大写。
VerticalAlignment vertical_alignment = 1 🔗
void set_vertical_alignment(value: VerticalAlignment)
VerticalAlignment get_vertical_alignment()
控制文本的垂直对齐方式。支持顶部对齐、居中对齐、底部对齐。
文本宽度(单位为像素),用于填充对齐。