Skip to content

ImGui

Client only ImGui is unavailable in a Reflex module’s server.lua.

API Display area
Global ImGui:Draw*() methods Directly over the full game screen. The module chooses the position.
ImGui:DrawDebugText() In the built-in debug block at the edge of the screen.
ImGuiWindow methods Inside a separate HUD window that players can move and resize in the interface editor.

Rendering is direct and does not depend on a built-in HUD module. Every element exists only in the frame in which its drawing method is called.

ImGui elements are drawn for the current frame only. Call drawing methods from Scheduler:OnFrame() to keep text or images visible.

Scheduler:OnFrame(function()
ImGui:DrawText(
"Tick: " .. tostring(Time.Tick),
Rect.new(20, 20, 280, 36),
18,
Color.new(1, 1, 1),
TextAnchor.MiddleLeft
)
end)

Create windows once when the module loads. Only their contents need to be redrawn every frame.

  • DrawText(), DrawTextPos(), and global texture methods use screen pixels with the origin in the top-left corner.
  • DrawTextUV() uses normalized viewport coordinates: (0, 0) is the bottom-left corner and (1, 1) is the top-right corner.
  • ImGuiWindow methods use coordinates inside the window content area.

The global fast-UI layer.

ImGui:DrawDebugText(text: string)

Adds a line to the debug block at the edge of the screen. Multiple calls in one frame are stacked vertically. Returns nil.

ImGui:DrawText(
text: string,
rect: Rect,
fontSize: number = 11,
color: Color? = nil,
alignment: TextAnchor = TextAnchor.MiddleCenter
)

Draws text inside the specified screen region. A built-in light text color is used when color is omitted. Returns nil.

ImGui:DrawTextPos(
text: string,
screenPosition: Vector2,
fontSize: number = 11,
color: Color? = nil,
alignment: TextAnchor = TextAnchor.MiddleCenter
)

Draws text at a screen position and automatically sizes its region to the content. Returns nil.

ImGui:DrawTextUV(
text: string,
viewportPosition: Vector2,
fontSize: number = 11,
color: Color? = nil,
alignment: TextAnchor = TextAnchor.MiddleCenter
)

Draws automatically sized text at a normalized viewport position. Values are converted using the current Screen.Width and Screen.Height. Returns nil.

ImGui:DrawTexture(texture: Texture, rect: Rect? = nil)

Draws a Texture in the specified screen region. When rect is omitted, the entire available global layer is used. Returns nil.

ImGui:DrawTextureColor(texture: Texture, color: Color, rect: Rect? = nil)

Draws a texture with a color tint. The color alpha controls transparency. Returns nil.

ImGui:AddImGuiWindow(id: string, title: string, rect: Rect): ImGuiWindow

Creates a floating HUD window whose position and size can be configured by the player in the UI editor.

  • id must be non-empty and unique within the module;
  • title is shown in the window header;
  • rect sets the initial position and size in screen pixels;
  • one module can create at most 16 windows.

Returns an ImGuiWindow. Returns nil for an empty id or after the window limit is reached.

A floating HUD window created with ImGui:AddImGuiWindow().

local window = ImGui:AddImGuiWindow(
"status",
"Module status",
Rect.new(40, 120, 320, 140)
)
if window ~= nil then
window:SetVisibilityTypes({
WindowVisibilityType.Match,
WindowVisibilityType.Spectate,
})
Scheduler:OnFrame(function()
window:DrawText(
"Module is active",
Rect.new(12, 12, 296, 32),
18,
Color.new(0.4, 1, 0.5),
TextAnchor.MiddleLeft
)
end)
end
ImGuiWindow:DrawText(
text: string,
rect: Rect,
fontSize: number,
color: Color,
alignment: TextAnchor = TextAnchor.MiddleCenter
)

Draws text inside the window content area. Unlike the global DrawText(), font size and color are required. Returns nil.

ImGuiWindow:DrawTexture(texture: Texture, rect: Rect? = nil)

Draws a texture inside the window. When rect is omitted, the image fills the available content area. Returns nil.

ImGuiWindow:DrawTextureColor(texture: Texture, color: Color, rect: Rect? = nil)

Draws a texture with a color tint inside the window. Returns nil.

ImGuiWindow:GetContentRenderSize(): Vector2

Returns the content area’s actual on-screen size in pixels, including UI scale and floating-window scale.

ImGuiWindow:SetVisibilityTypes(visibilityTypes: table): bool

Sets the modes in which the window is available in the HUD layout editor. Pass an array of WindowVisibilityType values. nil or an empty table leaves the window only in the editor’s all-modes filter.

Returns true for a valid window and false when its underlying window element is no longer available.

Text alignment relative to the supplied region or position.

Value Number Placement
TextAnchor.UpperLeft 0 Top left
TextAnchor.UpperCenter 1 Top center
TextAnchor.UpperRight 2 Top right
TextAnchor.MiddleLeft 3 Middle left
TextAnchor.MiddleCenter 4 Center
TextAnchor.MiddleRight 5 Middle right
TextAnchor.LowerLeft 6 Bottom left
TextAnchor.LowerCenter 7 Bottom center
TextAnchor.LowerRight 8 Bottom right

Floating HUD window visibility mode.

Value Number Mode
WindowVisibilityType.Match 0 Regular match
WindowVisibilityType.Spectate 1 Spectating a player
WindowVisibilityType.Killcam 2 Killcam