🪟 控件
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
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
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
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
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 Widgets ↔ NativeWidget Enums:
| Enum | Unreal Class | Is Panel |
|---|---|---|
NativeWidget.Border | Border | ✅ |
NativeWidget.Button | Button | ✅ |
NativeWidget.CheckBox | CheckBox | ✅ |
NativeWidget.Image | Image | ❌ |
NativeWidget.ProgressBar | ProgressBar | ❌ |
NativeWidget.RichTextBlock | RichTextBlock | ❌ |
NativeWidget.Slider | Slider | ❌ |
NativeWidget.Text | TextBlock | ❌ |
NativeWidget.ComboBox | ComboBox | ❌ |
NativeWidget.EditableText | EditableText | ❌ |
NativeWidget.EditableTextMultiLine | MultiLineEditableText | ❌ |
NativeWidget.SpinBox | SpinBox | ❌ |
NativeWidget.TextBox | EditableTextBox | ❌ |
NativeWidget.TextBoxMultiLine | MultiLineEditableTextBox | ❌ |
NativeWidget.CanvasPanel | CanvasPanel | ✅ |
NativeWidget.GridPanel | GridPanel | ✅ |
NativeWidget.HorizontalBox | HorizontalBox | ✅ |
NativeWidget.Overlay | Overlay | ✅ |
NativeWidget.ScaleBox | ScaleBox | ✅ |
NativeWidget.ScrollBox | ScrollBox | ✅ |
NativeWidget.SizeBox | SizeBox | ✅ |
NativeWidget.UniformGridPanel | UniformGridPanel | ✅ |
NativeWidget.VerticalBox | VerticalBox | ✅ |
NativeWidget.WrapBox | WrapBox | ✅ |
NativeWidget.BackgroundBlur | BackgroundBlur | ✅ |
✅ List of Supported Parameter Types
See all Supported Parameter Types in the Blueprint Page.
