UXML
Client only UI is unavailable in a Reflex module’s server.lua.
When to use UI
Section titled “When to use UI”UI loads persistent interfaces from UXML and lets Lua update them. It is suited to panels, menus, lists, and interactive windows. For simple text or images that are redrawn every frame, ImGui is usually more convenient.
The UI reference is split into several pages:
How the interface is processed
Section titled “How the interface is processed”The UXML loader creates a retained VisualElement tree that persists between frames until the module removes it. Build* methods immediately attach a root to a screen/HUD container, while Create* methods only create detached elements in memory.
After attachment, UI layout calculates sizes and positions, the renderer draws the tree, and the event system routes pointer/focus events to matching elements. Changing a property or style updates that same tree; the module does not need to redraw the whole interface every frame.
Where the result appears
Section titled “Where the result appears”| Creation method | Where the element lives |
|---|---|
BuildFromUxmlAbsolute() |
In the root screen layer. UXML/USS styles control placement; pointer input is disabled by default. |
BuildFromUxmlInteractive() |
In the same screen layer, with pointer interaction enabled. |
BuildFromUxml() / BuildFromUxmlAbsoluteCenter() |
In a separate HUD window exposed in the player’s interface editor. |
CreateFromUxml() / CreateVisualElement() / CreateLabel() |
Nowhere until the element is added to an already displayed tree with Add(). |
OpenWindow() does not create a second copy of the interface. It opens the supplied element as an exclusive window and applies the selected cursor, player-input, blur, and overlapping-UI rules.
Quick start
Section titled “Quick start”Place UXML and USS files in the module’s ui/ directory. Paths passed from Lua are relative to that directory.
<ui:UXML xmlns:ui="UnityEngine.UIElements"> <Style src="./styles.uss" /> <ui:VisualElement name="Root" class="status-panel"> <ui:Label name="lblStatus" text="Loading..." /> </ui:VisualElement></ui:UXML>.status-panel { position: absolute; left: 24px; top: 160px; padding: 12px; background-color: rgba(8, 13, 20, 0.9);}local root = UI:BuildFromUxmlAbsolute("StatusPanel.uxml")
if root ~= nil then local label = root:GetChild("lblStatus") label.text = "Module is active"endBuildFromUxmlAbsolute() immediately adds the root to the screen. Unlike ImGui, this code does not need to run every frame.
UI state
Section titled “UI state”These properties are read-only.
| Property | Type | Meaning |
|---|---|---|
UI.IsConsoleVisible |
boolean |
Whether the in-game console is open |
UI.IsCursorUnlocked |
boolean |
Whether the cursor is released |
UI.IsExclusiveWindowOpen |
boolean |
Whether an exclusive game or module window is open |
UI.IsWindowOpen |
boolean |
Whether this module has a window open through OpenWindow() |
Loading UXML
Section titled “Loading UXML”BuildFromUxmlAbsolute
Section titled “BuildFromUxmlAbsolute”UI:BuildFromUxmlAbsolute(path: string): VisualElementLoads UXML and adds it to the root UI. The element does not intercept the pointer until interaction is explicitly enabled. Returns the root, or nil if the file cannot be loaded.
BuildFromUxmlInteractive
Section titled “BuildFromUxmlInteractive”UI:BuildFromUxmlInteractive(path: string): VisualElementLoads UXML, adds it to the screen, and immediately enables pointer handling. Use it for buttons, text fields, and other interactive panels.
BuildFromUxmlAbsoluteCenter
Section titled “BuildFromUxmlAbsoluteCenter”UI:BuildFromUxmlAbsoluteCenter( path: string, id: string, title: string): VisualElementCreates a HUD window whose initial position is centered. id must be non-empty and unique within the module.
BuildFromUxml
Section titled “BuildFromUxml”UI:BuildFromUxml( path: string, id: string, title: string, anchorMode: string, posX: string, posY: string): VisualElementCreates a configurable HUD window with the requested anchor and initial position. Coordinates accept UI Toolkit values such as "24px" or "10%".
Supported anchorMode values:
| Value | Value | Value |
|---|---|---|
TopLeft |
TopMiddle |
TopRight |
MiddleLeft |
Middle |
MiddleRight |
BottomLeft |
BottomMiddle |
BottomRight |
local panel = UI:BuildFromUxml( "StatusPanel.uxml", "status-panel", "Status", "TopRight", "24px", "120px")CreateFromUxml
Section titled “CreateFromUxml”UI:CreateFromUxml(path: string): VisualElementCreates a tree from UXML without adding it to the screen. This is useful for repeated list rows: create an element, then add it to a container with parent:Add(child).
Creating elements without UXML
Section titled “Creating elements without UXML”UI:CreateVisualElement(): VisualElementUI:CreateLabel(): TextElementCreates an empty container or text element. Add it to an existing tree with Add().
Queries and lifecycle
Section titled “Queries and lifecycle”UI:Q(root: VisualElement, id: string): VisualElementroot:GetChild(name: string): VisualElementroot:GetChildAt(index: number): VisualElementQ() and GetChild() recursively find a descendant by name and return nil when no match exists. GetChildAt() accesses a direct child using a zero-based index.
UI:RemoveFromHierarchy(root: VisualElement)root:RemoveFromHierarchy()Detaches the element from its current parent while keeping the object available for later reuse.
UI:Delete(element: VisualElement): boolelement:Delete(): boolPermanently deletes the element and the wrappers created for its tree. Do not use old references after a successful deletion.
Exclusive windows
Section titled “Exclusive windows”OpenWindow
Section titled “OpenWindow”UI:OpenWindow( element: VisualElement, unlockCursor: boolean, lockInput: boolean, hideOverlappingUI: boolean, blurBackground: boolean): boolOpens an element as the module’s current exclusive window and applies the selected modes. Returns false when the element is unavailable, another exclusive window is already open, or player input is already locked by another window.
local menu = UI:BuildFromUxmlInteractive("Menu.uxml")
if menu ~= nil then UI:OpenWindow(menu, true, true, true, true)endCloseWindow
Section titled “CloseWindow”UI:CloseWindow(element: VisualElement, hideVisual: boolean = true): boolCloses the current window and releases the resources it acquired. With hideVisual = true, the element is hidden as well. Returns false if the supplied element is not the current window.
Controlling individual modes
Section titled “Controlling individual modes”Each method returns true when the mode was applied or released for the current window.
| Enable | Disable | Effect |
|---|---|---|
UI:LockCursor(element) |
UI:UnlockCursor(element) |
Capture or release the cursor |
UI:LockPlayerInput(element) |
UI:UnlockPlayerInput(element) |
Lock player controls |
UI:HideOverlappingUI(element) |
UI:ShowOverlappingUI(element) |
Hide overlapping game UI |
UI:BlurBackground(element) |
UI:UnblurBackground(element) |
Blur the background |
These resources are scoped to the active window. The methods return false for a regular panel that was not opened with OpenWindow().
HUD window visibility
Section titled “HUD window visibility”UI:SetWindowVisibilityTypes( element: VisualElement, visibilityTypes: table): boolSets the modes in which a HUD window is available. The method only works with elements created through BuildFromUxml() or BuildFromUxmlAbsoluteCenter().
UI:SetWindowVisibilityTypes(panel, { WindowVisibilityType.Match, WindowVisibilityType.Spectate,})| Value | Number | Mode |
|---|---|---|
WindowVisibilityType.Match |
0 |
Regular match |
WindowVisibilityType.Spectate |
1 |
Spectating |
WindowVisibilityType.Killcam |
2 |
Killcam |
Coordinates and strings
Section titled “Coordinates and strings”UI:GetMousePosition(): Vector2UI:ViewportToUiPoint(point: Vector3): Vector2UI:UiToViewportPoint(point: Vector2): Vector2UI:ToUpperInvariant(text: string): stringGetMousePosition()returns the current cursor position;ViewportToUiPoint()converts a viewport position to UI coordinates;UiToViewportPoint()performs the inverse conversion;ToUpperInvariant()converts text to uppercase without depending on the system language. It returnsnilfornil.
PlayerRankDisplay
Section titled “PlayerRankDisplay”PlayerRankDisplay:BindAgent( agent: Agent, rankContainer: VisualElement, rankImage: VisualElement)
PlayerRankDisplay:Clear( rankContainer: VisualElement, rankImage: VisualElement)Populates the standard rank display elements from an agent, or clears them.