学习
引擎类
GetTextBoundsParams
未复制

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处


概要
继承成员
代码示例
测量文本大小
local TextService = game:GetService("TextService")
-- 声明参数
local params = Instance.new("GetTextBoundsParams")
params.Text = "你好,世界!"
params.Font = Font.new("rbxasset://fonts/families/GrenzeGotisch.json", Enum.FontWeight.Thin)
params.Size = 20
params.Width = 200
local success, bounds = pcall(function()
return TextService:GetTextBoundsAsync(params)
end)
if success then
print(bounds)
end

API 参考
属性
Font
读取并联
功能: UI
GetTextBoundsParams.Font:Font

RichText
读取并联
功能: UI
GetTextBoundsParams.RichText:boolean

Size
读取并联
功能: UI
GetTextBoundsParams.Size:number

Text
读取并联
功能: UI
GetTextBoundsParams.Text:string

Width
读取并联
功能: UI
GetTextBoundsParams.Width:number

©2026 Roblox Corporation、Roblox、Roblox 标志及 Powering Imagination 是我们在美国及其他国家或地区的注册与未注册商标。