Skip to main content

WebUI

The WebUI class creates and manages web-based user interfaces within the game. It allows you to display web content (URLs or HTML files) as interactive widgets with full browser functionality powered by Chromium (CEF). WebUI supports all JS frameworks such as Vue.JS, React.JS, and more.

Authority: Client -- WebUI instances exist only on the client side.


Constructor

Blueprint Create WebUI WidgetScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayCreate WidgetClassWebUIOwning PlayerReturn ValueAdd to ViewportTarget

Constructor Parameters

TypeNameDefaultDescription
stringName--Unique identifier for logs.
stringPath--Web URL or HTML file path (e.g., "https://google.com" or "PackageName/Directory/index.html").
numberInputMode0Which input mode the UI is assigned (0 = Game Only, 1 = UI Only, 2 = Game and UI).

Methods

MethodParametersReturn TypeAuthorityDescription
BringToFront--voidClientBrings the interface to the top of the UI stack.
SetStackOrderorder: numbervoidClientSets the Z-Index for the UI in the stack.
SetInputModemode: numbervoidClientSets what type of input the UI receives. 0 = Game Only (No Input), 1 = UI Only (Full Input), 2 = Game and UI (Mouse Focus).
RegisterEventHandlereventName: string, callback: functionvoidClientRegisters a Lua event handler by name. The callback receives arguments sent from JavaScript and an optional callback function.
SendEventeventName: string, payload: anyvoidClientSends an event by name to the JavaScript layer through message events.
Destroy--voidClientDeactivates and destroys the WebUI instance.

Examples

Creating a HUD with Event Communication

Blueprint HUD with Event CommunicationScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayCreate WidgetClassWebUIOwning PlayerReturn ValueRegister Event HandlerTargetEvent Name"Test"CallbackSend EventTargetEvent Name"Test"Payload

Interactive Menu with Input Capture

Blueprint Interactive Menu with Input CaptureScroll to zoom · Drag to pan · Drag nodes to move
Event BeginPlayCreate WidgetClassWebUIOwning PlayerReturn ValueSet Input ModeTargetMode1

tip

Always call Destroy() on WebUI instances in the global onShutdown function to properly clean up resources.

tip

When using a key to set input mode, the key "released" event will automatically trigger. For example, binding a pressed key to open a WebUI will cause its "released" counterpart to trigger when you use SetInputMode(1).