Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
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 ( AutowrapMode value )
AutowrapMode get_autowrap_mode ( )
如果设置为 TextServer.AUTOWRAP_OFF 以外的值,则文本将在节点的边界矩形内自动换行。如果你调整节点大小,就会自动更改其高度,从而显示所有文本。要了解每种模式的行为方式,请参阅 AutowrapMode。
float curve_step = 0.5
用于近似贝塞尔曲线的步长(单位为像素)。
float depth = 0.05
生成的网格的深度,设为 0.0
时只有正面,此时的 UV 布局会变为让正面占据整张纹理。
Font font
用于显示文本的字体配置。
int font_size = 16
该 TextMesh 文本的字体大小。
HorizontalAlignment horizontal_alignment = 1
void set_horizontal_alignment ( HorizontalAlignment value )
HorizontalAlignment get_horizontal_alignment ( )
控制文本的水平对齐方式。支持左对齐、居中对齐、右对齐、和填充、或两端对齐。将其设置为 HorizontalAlignment 常量之一。
BitField<JustificationFlag> justification_flags = 163
void set_justification_flags ( BitField<JustificationFlag> value )
BitField<JustificationFlag> get_justification_flags ( )
行两端对齐规则。详见 JustificationFlag。
String language = ""
语言代码,用于文本塑形算法,如果留空则使用当前区域设置。
float line_spacing = 0.0
多行 TextMesh 中,行与行之间的垂直间距。
Vector2 offset = Vector2(0, 0)
文本绘制偏移(单位为像素)。
float pixel_size = 0.01
文本上一个像素宽度的大小,以 3D 缩放。
StructuredTextParser structured_text_bidi_override = 0
void set_structured_text_bidi_override ( StructuredTextParser value )
StructuredTextParser get_structured_text_bidi_override ( )
为结构化文本设置 BiDi 算法覆盖。
Array structured_text_bidi_override_options = []
void set_structured_text_bidi_override_options ( Array value )
Array get_structured_text_bidi_override_options ( )
设置 BiDi 覆盖的附加选项。
String text = ""
用于生成网格的文本。
Direction text_direction = 0
基础文本书写方向。
bool uppercase = false
如果为 true
,所有文本都将显示为大写。
VerticalAlignment vertical_alignment = 1
void set_vertical_alignment ( VerticalAlignment value )
VerticalAlignment get_vertical_alignment ( )
控制文本的垂直对齐方式。支持顶部对齐、居中对齐、底部对齐。请将其设置为 VerticalAlignment 常量。
float width = 500.0
文本宽度(单位为像素),用于填充对齐。