Skip to content

Stratkit UI Entities

Draws world-space UI authored as UGUI prefabs as instanced quads, without canvases.

  • Bake (Editor): a UGUI prefab is baked into a UiTemplateAsset: its RectTransforms, layout components (layout groups, ContentSizeFitter, LayoutElement), graphics (Image, Outline, SpriteDigitsGraphic) and effects. Game components plug in through IUiEntitiesNodeBaker.
  • Instances (Runtime): a UiInstance entity holds the state of every node of its template (UiNodeState). Feature code changes node state (active, colour, sprite, fill, number...) and marks the instance dirty; UiLayoutSystem then runs the port of the UGUI layout and writes the geometry of every graphic into the instance's range of the UiElementPool (one UiElementGpu per quad), mirrored in a GPU buffer.
  • Drawing: UiRenderSystem sorts the instances back to front every frame with UiSort, a stable natural merge sort that costs one pass while last frame's order still holds (panning, zooming) and O(n log n) at worst, then draws every element in one Graphics.RenderMeshPrimitives call per draw group (a base material with up to 8 sprite textures): the elements of an instance in slot order, the instances back to front, so overlapping UI blends as on a canvas. The shader includes Shaders/UiEntities.hlsl, which reads the element and its instance matrix from structured buffers by SV_InstanceID. Nothing is rebuilt when an instance moves, scales or changes a colour; instances are not culled on the CPU, every camera draws them with its own frustum.

The geometry and layout follow the UGUI sources (Image, LayoutGroup, HorizontalOrVerticalLayoutGroup, LayoutUtility, ContentSizeFitter, LayoutRebuilder) so the result matches the canvas pixel for pixel.