主题
TextUnit
场景中的三维文字单位,用于在世界空间渲染带样式设置的文本,可通过 Content 指定文字内容,通过 FontName、FontSize 控制字体与字号,并借助 TextColor、GradientColorEnable、GradientC...
概览
场景中的三维文字单位,用于在世界空间渲染带样式设置的文本,可通过 Content 指定文字内容,通过 FontName、FontSize 控制字体与字号,并借助 TextColor、GradientColorEnable、GradientColors、GradientAngle 实现纯色或渐变色文字,用 OutlineColor、OutlineWidth 添加描边。它同时提供 Width、Height、LineWrap、LineSpacing、HoriAlign、VertAlign 等排版属性,以及 OverflowStrategy、OverflowScrollSpeed、OverflowScrollSpacing 处理文字超框时的裁切或滚动。Position、Rotation、Scale 与 BindSocket 负责该文字在场景中的摆放与挂点绑定。
继承自
Unit;可通过World:CreateUnit("TextUnit", ...)创建;返回单个单位
属性
| 名称 | 类型 | 默认值 | 说明 |
|---|---|---|---|
Position | Vector3 | [0.0, 0.0, 0.0] | 文字在场景中的位置。 |
Rotation | Quaternion | [0.0, 0.0, 0.0, 1.0] | 文字的旋转(四元数)。 |
Width | Float | 5.0 | 文字框宽度。 |
Height | Float | 5.0 | 文字框高度。 |
Scale | Vector3 | [1.0, 1.0, 1.0] | 文字的缩放。 |
Content | String | "" | 要展示的文字内容。 |
FontName | TextFontType | Enums.TextFontType.HKXZYT_W9_GB | 文字使用的字体。 |
FontSize | Int | 100 | 文字字号。 |
Visible | Bool | true | 文字是否可见。 |
HoriAlign | HorizontalAlignmentType | Enums.HorizontalAlignmentType.ALIGN_LEFT | 文字的水平对齐方式。 |
VertAlign | VerticalAlignmentType | Enums.VerticalAlignmentType.ALIGN_TOP | 文字的垂直对齐方式。 |
LineWrap | Bool | true | 文字超出宽度时是否自动换行。 |
OverflowStrategy | TextOverflowStrategy | Enums.TextOverflowStrategy.OVERFLOW_NONE | 文本超出文字框时的处理策略。 |
OverflowScrollSpeed | Float | 2.0 | 超框跑马灯滚动速度。取值范围 [-5.0, 5.0]。 |
OverflowScrollSpacing | Float | 0 | 超框跑马灯滚动间距。取值范围 [0.0, 3.0]。 |
VerticalDirection | Bool | false | 文字是否纵向排列显示。 |
ReverseDirection | Bool | false | 纵向排列时是否从右到左显示。 |
LineSpacing | Float | 0.0 | 多行文字的行间距。取值范围 [0.0, 2.0]。 |
TextSkew | Float | 0.0 | 文本倾斜角度(度)。取值范围 [-45.0, 45.0]。 |
GradientColorEnable | Bool | false | 是否使用渐变色文字。 |
TextColor | Color | Color.New(255, 255, 255, 255) | 文本颜色(未开启渐变时生效)。 |
GradientColors | Array | - | 渐变色的颜色列表(开启渐变后生效)。 |
GradientAngle | Float | 0.0 | 渐变方向角度(度)。取值范围 [0.0, 180.0]。 |
OutlineColor | Color | Color.New(0, 0, 0, 255) | 文字描边颜色。 |
OutlineWidth | Float | 0.0 | 文字描边宽度。取值范围 [0.0, 7.0]。 |
BindSocket | String | "" | 文字绑定的骨骼挂点名称。 |
