Builtin Library
README.md
UiPanel
A UI panel component that renders a widget tree in one of three modes:
"2d"— egui viewport overlay (HUDs, menus, debug panels)."projected"— screen-space UI at the entity's world position viaworldToScreen. Always on top, no occlusion or lighting."3d": world-space billboard using egui render-to-texture. Respects depth/occlusion. The tree (inline, fromsetTree, or the screen asourcelibrary registers) is held on a hidden screen that is rasterized, styling and layout included, into arasterizeWidthxrasterizeHeighttexture every update; a quad in the child entity<name>_ui3dshows it, turned to face the active camera, and what the tree leaves transparent shows the world behind the quad. The quad is built in play.
Public fields: mode, layer, visible, tree (the widget tree, given inline), source (inline or "lib::<path>" / "@..." library module), offsetX/Y/Z, maxDistance, fontSize, textColor, background, billboard3dScale, theme, rasterizeWidth, rasterizeHeight.
Methods: setTree(tree), show(), hide(), toggle(), setMode(newMode), getScreenName().
A library module named by source is mounted with mount(ctx). When mount registers its own screen, the panel registers that screen again from its own code, so the screen is the panel's: its callbacks reach the panel's onCallback, which hands them to the onCallback the mount returned, and the screen is unregistered when the panel ends.
entity(id).component.add("UiPanel", {
mode = "2d",
layer = 10,
tree = { type = "label", props = { text = "HP: 100" } },
})