FText

FText

FText 函数用于根据 string 创建 FText 对象。

当 Mod 的界面需要与 UserWidget 相关的类交互,并调用它们的 SetText(FText("My New Text")) 方法时,此函数很有用。

参数(重载 #1)

根据传入的字符串创建新的 FText 对象。

| 类型 | 说明

---|----------|------------- 1 | string | 用于创建 FText 的文本内容

返回值

| 类型 | 说明

---|-------|------------- 1 | FText | 包含传入 string 的 FText 对象

示例

代码:

local my_text = FText("My Text")
print(string.format("Lua type: %s\n", type(my_text)))
print(string.format("Object type: %s\n", my_text:type()))
print(string.format("Content: %s\n", my_text:ToString()))

输出:

[Lua] Lua type: userdata
[Lua] Object type: FText
[Lua] Content: My Text

原文:docs/lua-api/global-functions/ftext.md · 固定提交 560411f18512 · 来源与 MIT 许可