跳至正文
版本:latest - a1.147.x ⚖️

🪟 控件

Failed to load class data.

The Widget class allows a very versatile way to create and use Unreal widgets as UI within the game.

备注

Most parameters are not exposed in the Widget class, and should be called using the method CallBlueprintEvent(), which will call the specific underlying Widget method.

🎒 示例

Creating a Simple a Native Text and adding it to screen

Client/Index.lua
local my_text = Widget(NativeWidget.Text)
my_text:CallBlueprintEvent("SetText", "Hello World!")
my_text:AddToViewport()
提示

SetText is a method from UTextBlock, the Widget associated to NativeWidget.Text.

Creating a Widgets with Childs

Client/Index.lua
local my_vertical_box = Widget(NativeWidget.VerticalBox)
my_vertical_box:AddToViewport()

local my_text = Widget(NativeWidget.Text)
my_text:CallBlueprintEvent("SetText", "Hello World!")

local my_button = Widget(NativeWidget.Button)

my_vertical_box:AddChild(my_text)
my_vertical_box:AddChild(my_button)

Using a WebUI as Image Brush

Client/Index.lua
local webui = WebUI("mywebui", "https://google.com", WidgetVisibility.Hidden)

local my_image = Widget(NativeWidget.Image)
my_image:CallBlueprintEvent("SetBrushFromMaterial", webui)
my_image:AddToViewport()
提示

SetBrushFromMaterial is a method from UImage, and expects a MaterialInstance as parameter. Passing WebUI, SceneCapture or Canvas converts it to it's internal Material automatically when being passed as parameter!

Subscribing for a Dispatcher

Client/Index.lua
local my_button = Widget(NativeWidget.Button)

-- Puts a text inside of it
local my_text = Widget(NativeWidget.Text)
my_text:CallBlueprintEvent("SetText", "Press Me!")
my_button:AddChild(my_text)

-- Binds the native OnClicked dispatcher
my_button:BindBlueprintEventDispatcher("OnClicked", function()
Console.Log("clicked!")
end)

-- Adds the button to viewport (will fill the whole screen)
my_button:AddToViewport()

📚 Libraries & Frameworks

Here a list of Community Created Libraries & Frameworks making use of Widgets expanding it's possibilities:

🛠 构造函数

Failed to load constructor data.

🦠 函数

Failed to load class data.

🚀 事件

Failed to load class data.

✅ NativeWidgets to Unreal Widgets Relation

List of the relation Unreal native WidgetsNativeWidget Enums:

EnumUnreal ClassIs Panel
NativeWidget.BorderBorder
NativeWidget.ButtonButton
NativeWidget.CheckBoxCheckBox
NativeWidget.ImageImage
NativeWidget.ProgressBarProgressBar
NativeWidget.RichTextBlockRichTextBlock
NativeWidget.SliderSlider
NativeWidget.TextTextBlock
NativeWidget.ComboBoxComboBox
NativeWidget.EditableTextEditableText
NativeWidget.EditableTextMultiLineMultiLineEditableText
NativeWidget.SpinBoxSpinBox
NativeWidget.TextBoxEditableTextBox
NativeWidget.TextBoxMultiLineMultiLineEditableTextBox
NativeWidget.CanvasPanelCanvasPanel
NativeWidget.GridPanelGridPanel
NativeWidget.HorizontalBoxHorizontalBox
NativeWidget.OverlayOverlay
NativeWidget.ScaleBoxScaleBox
NativeWidget.ScrollBoxScrollBox
NativeWidget.SizeBoxSizeBox
NativeWidget.UniformGridPanelUniformGridPanel
NativeWidget.VerticalBoxVerticalBox
NativeWidget.WrapBoxWrapBox
NativeWidget.BackgroundBlurBackgroundBlur

✅ List of Supported Parameter Types

See all Supported Parameter Types in the Blueprint Page.