KROYSDOCS
HomeWhat's newv0.1.0
PLUGIN SDK / UI / Ui

Ui

The editor's immediate-mode UI for plugin panels and settings pages, drawn with the editor theme (no Dear ImGui dependency). Valid only inside a draw callback. Begin*/End* pairs follow Dear ImGui's rule: call End* only when Begin* returned true; the host closes whatever a panel leaves open. Labels may carry "##id" suffixes to keep ids unique.

Kindclass
NamespaceKroys.Plugins
Members50
SourceUi.cs
EXAMPLE

In a plugin

A complete plugin that uses Ui.

Guides.cs
public sealed class ReportPanel : EditorPlugin
{
    public override void OnLoad() => Host.AddPanel(new PanelOptions("Report", "Scene Report"), Draw);

    private void Draw(Ui ui)
    {
        World? scene = Host.Document;
        if (scene is null)
        {
            ui.TextColored(ThemeColor.TextSecondary, "Open a scene to see its report.");
            return;
        }
        IReadOnlyList<Entity> entities = scene.Entities;
        ui.Text($"{entities.Count} entities");
        if (ui.BeginTable("entities", 2))
        {
            ui.TableSetupColumn("Name");
            ui.TableSetupColumn("Position");
            ui.TableHeadersRow();
            foreach (Entity entity in entities.Take(200))
            {
                ui.TableNextRow();
                ui.TableNextColumn();
                ui.Text(scene.GetName(entity));
                ui.TableNextColumn();
                ui.Text(scene.GetTransform(entity).Position.ToString("0.0", CultureInfo.InvariantCulture));
            }
            ui.EndTable();
        }
    }
}
REFERENCE

Members

Properties
#public float DeltaSeconds { get; }
Delta time of this frame.
property
#public float Width { get; }
Content width of the panel.
property
#public float Height { get; }
Content height of the panel.
property
#public float AvailableWidth { get; }
Remaining width on the line.
property
Methods
#public void Text(string text)
A line of text.
method
#public void TextWrapped(string text)
Text wrapped to the panel width.
method
#public void TextColored(ThemeColor color, string text)
Text in a theme colour.
method
#public void Heading(string text)
A heading.
method
#public void Icon(string iconName)
A Lucide icon ("plug", "play", "folder" ...).
method
#public bool Button(string label, ButtonStyle style = ButtonStyle.Default)
A button; true when clicked.
method
#public bool IconButton(string id, string iconName, string? tooltip = null)
An icon button with a tooltip; true when clicked.
method
#public bool Checkbox(string label, ref bool value)
A checkbox; true when toggled.
method
#public bool InputText(string label, ref string value, int capacity = 256, InputFlags flags = InputFlags.None)
A single-line text input; true when the text changed.
method
#public bool InputInt(string label, ref int value)
An integer input; true when changed.
method
#public bool InputFloat(string label, ref float value)
A float input; true when changed.
method
#public bool SliderFloat(string label, ref float value, float minimum, float maximum)
A slider; true when changed.
method
#public bool DragFloat3(string label, ref Vector3 value, float speed = 0.1f)
Three drag fields (vectors); true when changed.
method
#public bool Combo(string label, ref int index, IReadOnlyList<string> items)
A dropdown; true when the selection changed.
method
#public bool Selectable(string label, bool selected = false)
A selectable row; true when clicked.
method
#public bool ColorEdit4(string label, ref Vector4 rgba)
An RGBA colour editor; true when changed.
method
#public void ProgressBar(float fraction, string? overlay = null)
A progress bar (fraction 0..1).
method
#public void SameLine()
The next item stays on this line.
method
#public void Spacing()
Vertical space.
method
#public void Separator()
A horizontal line.
method
#public void SeparatorText(string text)
A line with a caption.
method
#public void Indent()
Indents the following items.
method
#public void Unindent()
Ends an indent.
method
#public void SetNextItemWidth(float width)
Width of the next item.
method
#public void BeginDisabled(bool disabled = true)
Starts a (possibly) disabled block; end it with EndDisabled.
method
#public void EndDisabled()
Ends a disabled block.
method
#public void PushId(string id)
Pushes an id scope (repeated widgets).
method
#public void PopId()
Pops an id scope.
method
#public Scope Disabled(bool disabled = true)
A disabled block as a scope: using (ui.Disabled(!ready)) { ... }.
method
#public Scope Id(string id)
An id scope: using (ui.Id(name)) { ... }.
method
#public bool BeginSection(string label, bool defaultOpen = true)
A collapsible section; call EndSection only when it returned true.
method
#public void EndSection()
Ends a section.
method
#public bool Section(string label, Action content, bool defaultOpen = true)
A collapsible section whose content is drawn by content when open.
method
#public bool BeginTable(string id, int columns, TableFlags flags = TableFlags.Borders | TableFlags.RowBackground)
A table; call EndTable only when it returned true.
method
#public void TableSetupColumn(string label, float width = 0.0f)
Declares a column (width 0: stretch).
method
#public void TableHeadersRow()
Draws the header row.
method
#public void TableNextRow()
Starts a row.
method
#public bool TableNextColumn()
Moves to the next column.
method
#public void EndTable()
Ends a table.
method
#public bool TreeNode(string label, TreeFlags flags = TreeFlags.None)
A tree node; call TreePop only when it returned true and it is not a leaf.
method
#public void TreePop()
Closes a tree node.
method
#public void Tooltip(string text)
Tooltip of the previous item.
method
#public bool IsItemHovered()
The previous item is hovered.
method
#public bool IsItemClicked()
The previous item was clicked.
method
#public Vector4 ThemeColorOf(ThemeColor color)
A theme colour as RGBA (0..1).
method
#public float ThemeMetricOf(ThemeMetric metric)
A theme metric (spacing, radius, scale, font size).
method
Signatures
public float DeltaSeconds { get; }
public float Width { get; }
public float Height { get; }
public void Text(string text)
public void TextWrapped(string text)
public void TextColored(ThemeColor color, string text)
public void Heading(string text)
public void Icon(string iconName)
public bool Button(string label, ButtonStyle style = ButtonStyle.Default)
public bool IconButton(string id, string iconName, string? tooltip = null)
public bool Checkbox(string label, ref bool value)
public bool InputText(string label, ref string value, int capacity = 256, InputFlags flags = InputFlags.None)
public bool InputInt(string label, ref int value)
public bool InputFloat(string label, ref float value)
public bool SliderFloat(string label, ref float value, float minimum, float maximum)
public bool DragFloat3(string label, ref Vector3 value, float speed = 0.1f)
public bool Combo(string label, ref int index, IReadOnlyList<string> items)
public bool Selectable(string label, bool selected = false)
public bool ColorEdit4(string label, ref Vector4 rgba)
public void ProgressBar(float fraction, string? overlay = null)
public void SameLine()
public void Spacing()
public void Separator()
public void SeparatorText(string text)
public void Indent()
public void Unindent()
public void SetNextItemWidth(float width)
public float AvailableWidth { get; }
public void BeginDisabled(bool disabled = true)
public void EndDisabled()
public void PushId(string id)
public void PopId()
public Scope Disabled(bool disabled = true)
public Scope Id(string id)
public bool BeginSection(string label, bool defaultOpen = true)
public void EndSection()
public bool Section(string label, Action content, bool defaultOpen = true)
public bool BeginTable(string id, int columns, TableFlags flags = TableFlags.Borders | TableFlags.RowBackground)
public void TableSetupColumn(string label, float width = 0.0f)
public void TableHeadersRow()
public void TableNextRow()
public bool TableNextColumn()
public void EndTable()
public bool TreeNode(string label, TreeFlags flags = TreeFlags.None)
public void TreePop()
public void Tooltip(string text)
public bool IsItemHovered()
public bool IsItemClicked()
public Vector4 ThemeColorOf(ThemeColor color)
public float ThemeMetricOf(ThemeMetric metric)

KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.