unity-uitoolkit
Unity UI Toolkit Skills
Use this module for Unity UI Toolkit only: UXML for structure, USS for styling, UIDocument for scene attachment, and PanelSettings for runtime rendering.
Requires Unity 2022.3+. Do not mix this module with
ui_*UGUI/Canvas skills. Localization: Match visible UI text to the user's language. Chinese conversation -> Chinese labels/placeholders/button text. USS class names and CSS variables stay English.
Guardrails
Mode: Full-Auto required
DO NOT (common hallucinations):
uitoolkit_create_button/uitoolkit_create_labeldo not exist -> useuitk_add_elementuitoolkit_set_styledoes not exist -> useuitk_add_uss_rule,uitk_remove_uss_rule, oruitk_modify_elementuitoolkit_create_canvasdoes not exist -> UI Toolkit usesUIDocument, not Canvasuitk_*andui_*are different systems. Do not mix UI Toolkit structure/styling assumptions into UGUI workflows- USS is not full CSS.
display:grid,box-shadow,calc(),@media,::before,z-index, and gradients are unsupported
Routing:
- For UGUI Canvas/Button/Text/Image -> use the
uimodule - For XR world-space Canvas conversion -> use
xr_setup_ui_canvas - For generated starter layouts -> use
uitk_create_from_template - For attaching an existing UXML to a scene object -> use
uitk_create_documentoruitk_set_document
Skills
File Skills
| Skill | Use | Key parameters |
|---|---|---|
uitk_create_uss |
Create USS file | savePath, content? |
uitk_create_uxml |
Create UXML file | savePath, content?, ussPath? |
uitk_read_file |
Read USS/UXML content | filePath |
uitk_write_file |
Overwrite file content | filePath, content |
uitk_delete_file |
Delete USS/UXML file | filePath |
uitk_find_files |
Search files by name/path | type?, folder?, filter?, limit? |
uitk_create_batch |
Create 2+ files in one call | items |
Scene Skills
| Skill | Use | Key parameters |
|---|---|---|
uitk_create_document |
Create UIDocument GameObject |
name, uxmlPath?, panelSettingsPath?, sortOrder?, parentName?/parentInstanceId?/parentPath? |
uitk_set_document |
Change UIDocument asset bindings | name/instanceId, uxmlPath?, panelSettingsPath? |
uitk_create_panel_settings |
Create PanelSettings asset | savePath, scaleMode, referenceResolutionX/Y, Unity 6 world-space options |
uitk_get_panel_settings |
Read PanelSettings values | assetPath |
uitk_set_panel_settings |
Update PanelSettings selectively | assetPath, changed fields only |
uitk_list_documents |
List scene UIDocuments | none |
uitk_inspect_document |
Inspect live VisualElement tree | name/instanceId/path, depth |
UXML Structure Skills
| Skill | Use | Key parameters |
|---|---|---|
uitk_add_element |
Add a child element | filePath, elementType, parentName?, elementName?, text?, classes? |
uitk_remove_element |
Remove by name |
filePath, elementName |
uitk_modify_element |
Change attributes/classes/text | filePath, elementName, text?, classes?, style?, newName?, bindingPath?, custom attribute fields |
uitk_clone_element |
Duplicate an element subtree | filePath, elementName, newName? |
uitk_inspect_uxml |
Parse UXML hierarchy | filePath, depth? |
USS Style Skills
| Skill | Use | Key parameters |
|---|---|---|
uitk_add_uss_rule |
Add or replace selector rule | filePath, selector, properties |
uitk_remove_uss_rule |
Remove selector rule | filePath, selector |
uitk_list_uss_variables |
Inspect design tokens / var() usage |
filePath |
Template and CodeGen Skills
| Skill | Use | Key parameters |
|---|---|---|
uitk_create_from_template |
Generate paired UXML+USS | template, savePath, name? |
uitk_create_editor_window |
Generate EditorWindow script | savePath, className, uxmlPath?, ussPath?, menuPath? |
uitk_create_runtime_ui |
Generate runtime MonoBehaviour query scaffold | savePath, className, elementQueries? |
Supported starter templates include menu, hud, dialog, settings, inventory, list, tab-view, toolbar, card, and notification.
Core Domain Knowledge
USS vs CSS
| Pattern | Supported in USS | What to do |
|---|---|---|
| Flex layout | Yes | Use flex-direction, flex-wrap, align-items, justify-content |
border-radius, opacity, overflow:hidden |
Yes | Safe to use |
| Transforms / transitions | Yes | translate, scale, rotate work |
| CSS variables | Yes | Prefer :root tokens |
display:grid / display:block / display:inline |
No | Everything is flex; emulate grids with wrapping rows |
box-shadow |
No | Fake with nested background element |
linear-gradient() / radial-gradient() |
No | Use image textures |
calc() / @media |
No | Use explicit values + PanelSettings.scaleMode |
::before / ::after |
No | Add a real child VisualElement |
z-index |
No | Later siblings render on top |
Common USS workarounds
| Need | USS-safe workaround |
|---|---|
| Shadow | Extra child VisualElement behind content |
| Responsive scaling | PanelSettings.scaleMode = ScaleWithScreenSize |
| Grid cards | flex-direction: row + flex-wrap: wrap + child widths |
| Circular avatar | Equal width/height + radius = half size + overflow:hidden |
| Pseudo decoration | Add an extra absolutely positioned child |
High-Frequency Parameters
| Skill | Parameters you usually need first |
|---|---|
uitk_create_panel_settings |
savePath, scaleMode, referenceResolutionX, referenceResolutionY |
uitk_create_document |
name, uxmlPath, panelSettingsPath, sortOrder? |
uitk_add_element |
filePath, elementType, parentName?, elementName?, text?, classes? |
uitk_modify_element |
filePath, elementName, changed attributes only |
uitk_add_uss_rule |
filePath, selector, properties |
PanelSettings choices
ScaleWithScreenSize: default for runtime HUD/menu UIConstantPixelSize: use when strict pixel mapping mattersConstantPhysicalSize: rare; only for physically sized UI requirements
Unity 6 world-space flows also need the scene-side document camera setup after configuring PanelSettings.
File and Structure Rules
- Prefer one UXML root that references shared token/style files through
<Style src="..."/>. - Keep USS next to UXML when possible so relative style references stay short.
- Use
uitk_inspect_uxmlbefore complex structural edits if you did not create the file yourself. uitk_create_uxmlcan auto-reference a stylesheet whenussPathis provided.
Workflow Notes
- Create USS/UXML first, then attach them through
uitk_create_document. - Runtime rendering needs a valid
PanelSettingsasset. - When USS and UXML are in the same folder, prefer
<Style src="MyStyle.uss" />; use a full asset path only for cross-folder references. - Start with design tokens, then component rules, then layout containers.
- For incremental edits, prefer
uitk_read_file-> edit ->uitk_write_file. - When creating 2+ files, use
uitk_create_batch. - Unity 6 world-space rendering uses PanelSettings world-space options plus the scene-side
UIDocumentcamera setup. - Use
uitk_create_from_templatewhen the user needs a starter screen fast; useuitk_add_element/uitk_add_uss_rulefor targeted edits on existing files.
Minimal Example
import unity_skills
unity_skills.call_skill("uitk_create_panel_settings",
savePath="Assets/UI/GamePanel.asset",
scaleMode="ScaleWithScreenSize",
referenceResolutionX=1920,
referenceResolutionY=1080
)
unity_skills.call_skill("uitk_create_uss",
savePath="Assets/UI/HUD.uss",
content=":root { --accent: #E8632B; } .title { color: var(--accent); }"
)
unity_skills.call_skill("uitk_create_uxml",
savePath="Assets/UI/HUD.uxml",
content="<?xml version=\"1.0\" encoding=\"utf-8\"?><engine:UXML xmlns:engine=\"UnityEngine.UIElements\"><Style src=\"HUD.uss\" /><engine:Label class=\"title\" text=\"Start\" /></engine:UXML>"
)
unity_skills.call_skill("uitk_create_document",
name="HUD",
uxmlPath="Assets/UI/HUD.uxml",
panelSettingsPath="Assets/UI/GamePanel.asset"
)
Exact Signatures
Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.
Load USS_REFERENCE.md before generating non-trivial USS systems, layout patterns, component styles, or complete examples.
More from besty0728/unity-skills
unity-skills
Unity Editor automation via REST API — create scripts, analyze scenes, manage assets, control editor, and orchestrate workflows. Triggers: Unity, Unity Skills, in Unity, automate Unity, editor automation, create script, scene summary, build scene, 全自动模式, full auto, semi-auto, 半自动, Unity自动化, Unity编辑器, Unity技能, 操作Unity,在Unity中.
56unity-ui
Unity UI creation. Use when users want to create Canvas, Button, Text, Image, or other UI elements. Triggers: UI, canvas, button, text, image, panel, slider, toggle, UGUI, 界面, 按钮, 文本, 面板.
20unity-scriptableobject
ScriptableObject management. Use when users want to create, read, or modify ScriptableObject assets. Triggers: scriptableobject, SO, data asset, config, settings asset, 数据资产, 配置文件.
19unity-editor
Unity Editor control. Use when users want to enter play mode, select objects, undo/redo, or execute menu commands. Triggers: play, stop, pause, select, undo, redo, menu, editor, Unity编辑器, Unity播放, Unity撤销, Unity选择.
18unity-light
Unity lighting control. Use when users want to create or configure lights (Directional, Point, Spot, Area). Triggers: light, lighting, directional light, point light, spot light, shadows, intensity, 灯光, 光照, 阴影.
17unity-material
Unity material and shader properties. Use when users want to create materials, set colors, textures, emission, or shader properties. Triggers: material, shader, color, texture, emission, albedo, metallic, smoothness, 材质, 颜色, 纹理, 发光.
17