Ir para o conteúdo principal
Version: bleeding-edge 🩸

🪟 Widget

The Widget class supports spawning Unreal Widgets classes through scripting and manipulate them such as Blueprints!


💂Authority
This class can only be spawned on 🟧 Client side.
👪Inheritance
This class shares methods and events from .
🧑‍💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!

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

Note

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.

🎒 Examples

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()
tip

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()
tip

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:

🛠 Constructors

UserWidget Constructor

Spawns a Widget passing a UserWidget blueprint

local my_widget = Widget(blueprint_path)
TypeNameDefaultDescription
blueprint_path Required parameter A custom UserWidget Blueprint to spawn

Native Widget Constructor

Spawns a Widget passing a NativeWidget enum

local my_widget = Widget(native_widget)
TypeNameDefaultDescription
native_widget Required parameter One of the native Widgets to spawn

🦠 Functions

Inherited Entity Functions
Widget inherits from Base Entity Class, sharing it's methods and functions:
Base Entityscripting-reference/classes/base-classes/Entity
ReturnsNameDescription
Calls a custom remote event directly on this entity to all Players
Calls a custom remote event directly on this entity to a specific Player
Calls a custom remote event directly on this entity
Destroys this Entity
of Gets a list of all values keys
Gets the class of this entity
Gets the universal network ID of this Entity (same on both client and server)
Gets a Value stored on this Entity at the given key
Recursively checks if this entity is inherited from a Class
Returns true if this Entity is valid (i.e. wasn't destroyed and points to a valid Entity)
Sets a Value in this Entity
Subscribes to an Event on this specific entity
Subscribes to a custom event called from server on this specific entity
Unsubscribes all callbacks from this Event in this Entity within this Package, or only the callback passed
ReturnsNameDescription
Adds a new child widget to this Widget container, if this is a Panel
Adds it to the game's viewport and fills the entire screen
Assigns and Binds a Blueprint Event Dispatcher
Puts this Widget in the front of all WebUIs and Widgets
of Calls a Blueprint Event or Function
Gets a Blueprint Property/Variable value
Returns the current WebUI visibility
Sets a Blueprint Property/Variable value directly
Sets the Layout as Canvas on Screen
Sets the widget for a given slot by name, if this is a UserWidget
Enables the focus on this Widget (i.e. can receive Keyboard input and will trigger input events)
Sets the visibility in screen
Widget3DSpawns a 3D Widget actor rendering this Widget in the world
Unbinds a Blueprint Event Dispatcher

AddChild

Adds a new child widget to this Widget container, if this is a Panel

my_widget:AddChild(other)
TypeParameterDefaultDescription
WebUI or Widgetother Required parameter No description provided

AddToViewport

Adds it to the game's viewport and fills the entire screen

my_widget:AddToViewport()

BindBlueprintEventDispatcher

Assigns and Binds a Blueprint Event Dispatcher

— Returns (the callback itself).

local ret = my_widget:BindBlueprintEventDispatcher(dispatcher_name, callback)
TypeParameterDefaultDescription
dispatcher_name Required parameter Event Dispatcher name
callback Required parameter Callback function to call

BringToFront

Puts this Widget in the front of all WebUIs and Widgets. Note: You can only call it if the Widget is parented to the Viewport!

my_widget:BringToFront()

CallBlueprintEvent

Calls a Blueprint Event or Function
Returns all Function return values on Client Side

— Returns of (the function return values).

local ret_01, ret_02, ... = my_widget:CallBlueprintEvent(event_name, arguments...?)
TypeParameterDefaultDescription
event_name Required parameter Event or Function name
arguments...?nilSequence of arguments to pass to the event

GetBlueprintPropertyValue

Gets a Blueprint Property/Variable value

— Returns (the value).

local ret = my_widget:GetBlueprintPropertyValue(property_name)
TypeParameterDefaultDescription
property_name Required parameter No description provided

See also SetBlueprintPropertyValue.


GetVisibility

Returns the current WebUI visibility

— Returns .

local ret = my_widget:GetVisibility()

See also SetVisibility.


SetBlueprintPropertyValue

Sets a Blueprint Property/Variable value directly

my_widget:SetBlueprintPropertyValue(property_name, value)
TypeParameterDefaultDescription
property_name Required parameter No description provided
value Required parameter No description provided

See also GetBlueprintPropertyValue.


SetCanvasLayout

Sets the Layout as Canvas on Screen.

Note: This method only works if this Widget is child of a Canvas Panel.

Anchors:

my_widget:SetCanvasLayout(screen_location/offset_left_top?, size/offset_right_bottom?, anchors_min?, anchors_max?, alignment?)
TypeParameterDefaultDescription
Vector2Dscreen_location/offset_left_top?Vector(0, 0)No description provided
Vector2Dsize/offset_right_bottom?Vector(0, 0)No description provided
Vector2Danchors_min?Vector(0, 0)No description provided
Vector2Danchors_max?Vector(1, 1)No description provided
Vector2Dalignment?Vector(0.5, 0.5)No description provided

SetContentForSlot

Sets the widget for a given slot by name, if this is a UserWidget

my_widget:SetContentForSlot(slot_name, widget)
TypeParameterDefaultDescription
slot_name Required parameter No description provided
Widget or widget Required parameter Pass it nil to remove it

SetFocus

Enables the focus on this Widget (i.e. can receive Keyboard input and will trigger input events
Note: Only one Widget can have focus per time.

my_widget:SetFocus()

SetVisibility

Sets the visibility in screen

my_widget:SetVisibility(visibility)
TypeParameterDefaultDescription
visibility Required parameter No description provided

See also GetVisibility.


SpawnWidget3D

Spawns a 3D Widget actor rendering this Widget in the world

— Returns Widget3D.

local ret = my_widget:SpawnWidget3D(location?, rotation?, widget_space?, auto_size?, size?, auto_repaint_rate?, pivot?)
TypeParameterDefaultDescription
Vectorlocation?Vector(0, 0, 0)No description provided
Rotatorrotation?Rotator(0, 0, 0)No description provided
widget_space?WidgetSpace.WorldNo description provided
auto_size?falseNo description provided
Vector2Dsize?Vector2D(500, 500)Only works if auto_size = false
auto_repaint_rate?-1Leaves -1 to repaint every frame
Vector2Dpivot?Vector2D(0.5, 0.5)No description provided

UnbindBlueprintEventDispatcher

Unbinds a Blueprint Event Dispatcher

my_widget:UnbindBlueprintEventDispatcher(dispatcher_name, callback?)
TypeParameterDefaultDescription
dispatcher_name Required parameter Event Dispatcher name
callback? Required parameter Optional callback to unbind

🚀 Events

Inherited Entity Events
Widget inherits from Base Entity Class, sharing it's events:
Base Entityscripting-reference/classes/base-classes/Entity
NameDescription
Triggered when a new Class is registered with the Inheriting System
Triggered when an Entity is destroyed
Triggered when an Entity is spawned/created
Triggered when an Entity has a value changed with :SetValue()

This class doesn't have own events.

✅ NativeWidgets to Unreal Widgets Relation

List of the relation Unreal native Widgets 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.