Operations
UI Operations
CreateUICanvas
Create a UI canvas entity — the root of a UI hierarchy. All UI elements must be descendants of a canvas.
| Parameter | Type | Required | Description |
|---|---|---|---|
canvas_name | string | Yes | Canvas entity name |
render_mode | string | No | "screen_space" (HUD/menus), "world_space" (3D positioned), or "render_to_texture" |
sort_order | integer | No | Render order for multiple canvases (higher = on top, default: 0) |
parent_guid | string | No | Parent entity GUID |
{
"op": "CreateUICanvas",
"params": {
"canvas_name": "GameHUD",
"render_mode": "screen_space",
"sort_order": 0
}
}
AddUIElement
Add a UI element with UIRectTransformComponent and a widget component as a child of a canvas or another UI element.
| Parameter | Type | Required | Description |
|---|---|---|---|
element_name | string | Yes | Element entity name |
widget_type | string | Yes | Widget component type (see below) |
parent_guid | string | No | Parent canvas or UI element GUID |
widget_data | object | No | Initial widget data (uses defaults if omitted) |
Widget Types
| Type | Description |
|---|---|
UITextComponent | Text label |
UIImageComponent | Image display |
UIButtonComponent | Clickable button |
UIPanelComponent | Background panel |
UISliderComponent | Numeric slider |
UIToggleComponent | Checkbox/switch |
UIProgressBarComponent | Progress bar |
UIInputFieldComponent | Text input |
UIDropdownComponent | Dropdown selector |
Example: HUD with Score and Health
[
{
"op": "CreateUICanvas",
"params": { "canvas_name": "HUD", "sort_order": 0 }
},
{
"op": "AddUIElement",
"params": {
"element_name": "ScoreLabel",
"widget_type": "UITextComponent",
"widget_data": {
"text": "Score: 0",
"font_size": 24,
"color": { "x": 1, "y": 1, "z": 1, "w": 1 },
"horizontal_alignment": "left"
}
}
},
{
"op": "AddUIElement",
"params": {
"element_name": "HealthBar",
"widget_type": "UIProgressBarComponent",
"widget_data": {
"fill_amount": 1.0,
"fill_color": { "x": 0.8, "y": 0.1, "z": 0.1, "w": 1 },
"direction": "left_to_right"
}
}
}
]