▫️UI Examples

This page contains examples for creating UI for your mod using the built-in ImGui library.Everything you need to know about Dear ImGui can be found here and here.

Basic Window

ImGui.SetNextWindowPos(100, 500, ImGuiCond.FirstUseEver) -- set window position x, yImGui.SetNextWindowSize(300, 600, ImGuiCond.Appearing) -- set window size w, h​if ImGui.Begin("Unique Window Name") thenImGui.Text("Hello World")-- more window contents hereendImGui.End()

if ImGui.Button("Pop Button", 120, 0) thenImGui.OpenPopup("Delete?")end​if ImGui.BeginPopupModal("Delete?", true, ImGuiWindowFlags.AlwaysAutoResize) thenImGui.Text("This is a popup")if ImGui.Button("Close") then ImGui.CloseCurrentPopup() endImGui.EndPopup()end

Combo Box with Selectables

local DropdownOptions = {"1", "2", "3", "4", "5"}local DropdownSelected = "1"​if ImGui.BeginCombo("##My Combo Box", DropdownSelected) then -- Remove the ## if you'd like for the title to display above combo box​for i, option in ipairs(DropdownSelected) do​if ImGui.Selectable(option, (option == DropdownSelected)) thenDropdownSelected = optionImGui.SetItemDefaultFocus()end​end​ImGui.EndCombo()end

Button

if ImGui.Button("Click Me!", 100, 20) then -- Label, width, height - Use -1 as width for button to span available horizontal space-- do stuff here when button is clickedendregisterForEvent("onUpdate", function()if btn thenprint("You pressed me!")emdend)​registerForEvent("onDraw", function()btn = ImGui.Button("Click me I'm a Sexy Button", 250, 25)end)

Last updated