Razorbill
Operations

UI Operations

CreateUICanvas

Create a UI canvas entity — the root of a UI hierarchy. All UI elements must be descendants of a canvas.

ParameterTypeRequiredDescription
canvas_namestringYesCanvas entity name
render_modestringNo"screen_space" (HUD/menus), "world_space" (3D positioned), or "render_to_texture"
sort_orderintegerNoRender order for multiple canvases (higher = on top, default: 0)
parent_guidstringNoParent 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.

ParameterTypeRequiredDescription
element_namestringYesElement entity name
widget_typestringYesWidget component type (see below)
parent_guidstringNoParent canvas or UI element GUID
widget_dataobjectNoInitial widget data (uses defaults if omitted)

Widget Types

TypeDescription
UITextComponentText label
UIImageComponentImage display
UIButtonComponentClickable button
UIPanelComponentBackground panel
UISliderComponentNumeric slider
UIToggleComponentCheckbox/switch
UIProgressBarComponentProgress bar
UIInputFieldComponentText input
UIDropdownComponentDropdown 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"
      }
    }
  }
]

On this page