Repository navigation
en ui overview
中文 | English | Docs | Repository
Nullus UI is retained-mode: a document describes an element tree, and the runtime builds instances from it, lays them out, and produces a draw snapshot. UI can be drawn on screen or attached to objects in world space.
| Component | Purpose |
|---|---|
UIDocument |
JSON-loaded document definition with the element tree and styles |
UIDocumentInstance |
Runtime instance holding the element tree, generation, and signal bus |
UIElement |
Element node with type, layout, style, text, and interaction state |
UIStyleSheet |
State-aware style sheet applying per-state patches |
UIInputRouter |
Hit testing, pointer capture, focus, and keyboard dispatch |
UIAnimationPlayer |
Track-based animation (currently opacity tracks) |
UIDataContext |
Path-addressed data binding with change subscriptions |
UISignalBus |
Named signals and subscriptions |
UILocalizationTable |
Localization table with a fallback locale |
UICanvasComponent |
Connects a document instance to the scene, render mode, and sorting |
UIDocument is currently at schema version 1. Each node carries:
| Field | Notes |
|---|---|
nodeGuid |
Node identity, preserved across reloads |
type |
Element type |
name / className
|
Name and style class |
layout |
Layout parameters |
style |
Inline style |
text / passwordMode
|
Text and password mode |
requiresRenderTarget |
Whether a dedicated render target is needed |
textureId / textureGeneration
|
Texture reference and generation |
fontAssetId / fontPixelSize
|
Font and size |
children |
Child nodes |
Panel, Image, NineSlice, Text, RichText, Button, Toggle, Radio, Slider, ProgressBar, TextField, Dropdown, ScrollView, Scrollbar, and ListView.
| Mode | Notes |
|---|---|
Absolute |
Absolute coordinates |
Stack |
Single-direction stacking |
Flex |
Flexible layout |
Grid |
Grid layout |
Overlay |
Overlapping children |
Scroll |
Scrollable container |
Layout runs in UpdateLayout(viewportSize, dpiScale). The instance caches the last layout and skips recomputation when neither the viewport nor the DPI changed, while still producing a frame-scoped snapshot.
UIStyleSheet supports style patches that apply per state. Available state bits are Hovered, Pressed, Focused, Disabled, Checked, Selected, and Invalid.
A patch can override background color, foreground color, opacity, and similar properties. The input router maintains states during interaction, and elements also store hovered, checked, selected, and invalid flags.
UIInputRouter handles:
-
HitTestfor position-based hit testing -
DispatchPointer/DispatchScrollfor pointer and wheel events -
DispatchKey/DispatchTextInputfor keyboard and text input -
Navigatefor directional focus navigation -
CapturePointer/ReleasePointerfor pointer capture -
Focus/ClearFocusfor focus management
Events build a parent path before dispatch, and elements manage subscriptions through UIEventListenerHandle.
UIAnimationPlayer uses a track model: AddOpacityTrack adds an opacity track for one element and returns a track handle; Play, Stop, and Tick drive time; RemoveTrack and Clear release tracks. It uses unscaled time by default.
Only opacity tracks exist today. A fuller property and curve animation system is planned; see the Roadmap.
-
UIDataContextstores path-to-value mappings where the value isbool,int64,double,string, a color, or a 2D vector.Setraises change notifications andSubscribesubscribes by path. -
UISignalBusprovides named signals:Connectsubscribes andEmitbroadcasts and returns the notification count.
Together they decouple UI from gameplay logic: the UI never holds script objects directly, and scripts never have to walk the element tree.
UILocalizationTable is at schema version 1 and carries a locale plus a fallback locale. Lookup prefers the current locale and falls back when a key is missing.
UICanvasComponent provides three render modes:
| Mode | Notes |
|---|---|
ScreenOverlay |
Screen overlay without scene depth |
ScreenCamera |
Bound to a camera and able to participate in depth testing |
World |
World-space rendering |
World-space rendering has three path values: Auto (choose automatically), Direct (draw straight to the target), and RenderTarget (render to a texture first). Use RenderTarget when other materials need to sample the result.
Other rendering-related properties:
| Property | Notes |
|---|---|
sortOrder / sortLayer
|
Sort order and layer |
cameraId |
Associated camera |
referenceResolution |
Reference resolution |
dpiScaleMode |
ConstantPixelSize / ScaleWithScreenSize / ConstantPhysicalSize
|
dpiMatch |
Blend factor for the scaling mode |
pixelsPerUnit |
World-space pixel density |
depthTest / depthWrite
|
Depth test and write |
alwaysOnTop |
Draw on top |
worldSize |
World-space size |
updatePolicy |
EveryFrame / OnDemand / Manual
|
updatePolicy decides how often the document instance updates: every frame, on demand, or manually triggered. A static interface set to OnDemand avoids rebuilding layout and geometry every frame.
UIDocumentInstance::Reload rebuilds the element tree and preserves compatible per-node state keyed by nodeGuid. Reload increments the generation, which invalidates element handles held by scripts, matching the native object hot reload semantics. Never cache element handles across a reload.
Scripts reach the UI through UICanvasComponent: GetElementHandle(name) resolves a handle from a name, after which text, values, checked state, and focus can be read and written. Lua never holds 64-bit handles directly; name-based access resolves them internally.
The editor provides a UIDocumentDesigner panel and a document design model for opening and editing UI documents inside the editor. See UI Designer and Editor Extensions.
- Animation covers opacity tracks only
- Rich text layout and full text wrapping are not implemented
- There is no cross-project theming or style reuse mechanism
- UI documents share the object graph with scenes and Prefabs, but the document itself is a separate JSON format
- UI Designer and Editor Extensions edits and extends the UI inside the editor.
-
Scripting API Reference lists the
UICanvasComponentmembers.
Nullus Engine
中文
- 认识 Nullus
- 安装与快速入门
- 使用编辑器
- 场景与对象
- Prefab 工作流
- 资产与内容管线
- 渲染、材质与光照
- 大场景与资源管理
- 游戏逻辑与脚本
- 用户界面
- 动画与角色
- 物理与交互
- 音频、特效与媒体
- AI 与联网
- 平台、构建与发布
- 扩展与引擎架构
- 调试、性能与质量
- 参考手册
- 示例与发展路线
English
- Getting to Know Nullus
- Install and Quick Start
- Using the Editor
- Scenes and Objects
- Prefab Workflow
- Assets and Content Pipeline
- Rendering, Materials, and Lighting
- Large Scenes and Resource Management
- Gameplay and Scripting
- User Interface
- Animation and Characters
- Physics and Interaction
- Audio, Visual Effects, and Media
- AI and Networking
- Platforms, Builds, and Releases
- Extending the Engine
- Debugging, Performance, and Quality
- Reference
- Examples and Roadmap