主题
EUISimpleRichTextLabel
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- EUINodeBase(34 属性 / 8 函数 / 4 事件)
- [EUISimpleRichTextLabel](20 属性)
- EUINodeBase(34 属性 / 8 函数 / 4 事件)
继承成员
2 个来源 / 38 属性 / 33 函数 / 10 事件
- 来自 EUINodeBase(34 属性 / 8 函数 / 4 事件)
- 属性:
Visible、Position、Anchor、FlippedX、FlippedY、Size、Rotation、Opacity、TouchBeginAudio、TouchEndAudio、TouchClickAudio、TouchbeginEvent、ClickEvent、TouchendEvent、LongtouchEvent、ShowEvent、HideEvent、TouchEnabled、SwallowTouchEnabled、TopAdaptMode、TopAdaption、BottomAdaptMode、BottomAdaption、LeftAdaptMode、LeftAdaption、RightAdaptMode、RightAdaption、AnchorXAdaptMode、AnchorXAdaption、AnchorYAdaptMode、AnchorYAdaption、LocalZOrder、LayoutOrder、Scale - 函数:
RemoveFromParent、GetFullPath、TweenPosition、TweenSize、TweenSizeAndPosition、TweenOpacity、Retain、Release - 事件:
OnTouchBegan、OnTouchMoved、OnTouchEnded、OnClicked
- 属性:
- 来自 Unit(4 属性 / 25 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
一种用于在界面层级中展示富文本内容的界面单位,可通过文本、颜色、字号、字体等属性控制显示效果,同时支持描边、阴影、斜体、对齐方式、字间距与行间距等排版设置。它还提供自动缩小字号、超框策略与爆框策略等自适应能力,适合轻量级文本展示需求。
适用场景
在需要显示带样式短文本的界面场景中使用,例如在界面根节点下创建提示文字或信息标签,通过读写文本与样式属性实时更新显示内容。
使用要点
通过世界创建单位接口创建实例,创建时需传入父节点以及位置、尺寸等初始配置,父节点通常取自玩家界面管理器中的根节点。创建成功后可直接设置文本、颜色、字体大小、描边和阴影等属性来更新显示效果,无需额外调用其他接口。
注意事项
实例只能通过创建单位接口生成,不能直接构造;创建时必须提供有效的父节点,否则无法挂载到界面层级。文本自适应相关配置如自动缩小字号、超框策略与爆框策略需按需设置,创建后通过属性读写即可完成调整。
代码示例
创建 EUISimpleRichTextLabel 实例
lua
-- @runtime client
local Players = game:GetService("Players")
local World = game:GetService('World')
local localPlayer = Players.LocalPlayer
if localPlayer == nil then return end
local rootNode = localPlayer.PlayerGui.EuiManager:GetRootNode()
local eUISimpleRichTextLabel = World:CreateUnit("EUISimpleRichTextLabel", { Parent = rootNode })
print('EUISimpleRichTextLabel 已创建:', eUISimpleRichTextLabel.Name)属性 (20)
| Name | 类型 | 默认值 | 说明 |
|---|---|---|---|
Text | String | SimpleRichText | 富文本标签显示的文本内容。 |
TextColor | Color | [255, 255, 255, 255] | 文本颜色,设置富文本标签中文本的显示颜色。 |
FontSize | Int | 42 | 富文本标签的字体大小,控制文本在标签中的显示尺寸。 |
Font | TextFontType | Enums.TextFontType.HKXZYT_W9_GB | 富文本标签使用的字体,类型为 TextFontType,用于指定标签文本渲染时采用的字体。 |
OutlineEnabled | Bool | false | 是否开启文本描边效果。 |
OutlineColor | Color | [0, 0, 0, 0] | 描边颜色,用于设置文本描边效果的颜色。 |
OutlineWidth | Int | 1 | 描边宽度,控制文本描边的粗细程度。 |
OutlineOpacity | Float | 1.0 | 描边透明度,控制文本描边的不透明程度。 |
ShadowEnabled | Bool | false | 是否开启文本阴影效果。 |
ShadowColor | Color | [0, 0, 0, 0] | 阴影颜色,设置文本阴影效果的颜色。 |
ShadowOffset | Vector2 | [1, 1] | 阴影偏移,控制文本阴影相对文本主体的偏移方向和距离。 |
ItalicEnabled | Bool | false | 是否开启斜体显示,控制文本是否以斜体样式呈现。 |
TextHorizontalAlignment | Int | 0 (Left) | 文本水平对齐方式,控制文本在标签区域内的水平位置。 |
TextVerticalAlignment | Int | 0 (Top) | 文本垂直对齐方式,控制文本在标签区域内的垂直位置。 |
TextSpacing | Int | 0 | 字间距,控制文本中字符之间的水平间距。 |
LineSpacing | Int | - | 行间距,控制富文本多行内容之间的垂直间距。 |
AutoSizeEnabled | Bool | false | 是否自动缩小字号,用于在文本超出标签尺寸时自动调整字号以适应显示区域。 |
MinFontSize | Int | 12 | 最小字号,用于限制文本字号缩小的下限。 |
OverflowStrategy | Int | 3 (AutoScroll) | 超框策略,控制文本内容超出标签显示区域时的处理方式。 |
ResetSizePolicy | Int | 0 (AutoScroll) | 爆框策略,控制文本内容超出标签显示区域后标签尺寸的处理方式。 |
