agentleFS
batihandevbatihandev/unity-mcp-skills/skills/uitoolkit/SKILL.md

unity-uitoolkit

Skill7 starsChanged 7 months agoMITView on GitHub

Use when working with UI Toolkit (UITK) for Unity — create/edit USS stylesheets and UXML layouts, configure UIDocument in scenes.

The file

We split this skill into the rules it gives an agent

11 rules. About 0 are common, 2 are distinctive, and 9 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 9

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use this module for Unity UI Toolkit only: UXML for structure, USS for styling, UIDocument for scene attachment, and PanelSettings for …

    line 10
  2. Very specific:

    Check ../../mcp-tools.md first for a dedicated official Unity MCP tool.

    line 13
  3. Very specific:

    If no native tool covers the operation, use ../../recipes/uitoolkit/<command>.md.

    line 14
  4. Very specific:

    Prefer one UXML root that references shared token/style files through <Style src="..."/>.

    line 135
  5. Distinctive:

    Keep USS next to UXML when possible so relative style references stay short.

    line 136
  6. Very specific:

    Use uitk_inspect_uxml before complex structural edits if you did not create the file yourself.

    line 137
  7. Very specific:

    Create USS/UXML first, then attach them through uitk_create_document.

    line 142
  8. Very specific:

    When USS and UXML are in the same folder, prefer <Style src="MyStyle.uss" />.

    line 144
  9. Distinctive:

    Start with design tokens, then component rules, then layout containers.

    line 145
  10. Very specific:

    When creating 2+ files, use uitk_create_batch.

    line 147
  11. Very specific:

    Use uitk_create_from_template when the user needs a starter screen fast.

    line 149

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Unity UI Toolkit Skills

When to Use

Use this module for Unity UI Toolkit only: UXML for structure, USS for styling, UIDocument for scene attachment, and PanelSettings for runtime rendering.

Routing:

  • Check ../../mcp-tools.md first for a dedicated official Unity MCP tool.
  • If no native tool covers the operation, use ../../recipes/uitoolkit/<command>.md.
  • For UGUI Canvas/Button/Text/Image → use the ui module.
  • For XR world-space Canvas conversion → use xr_setup_ui_canvas.
  • For attaching an existing UXML to a scene object → use uitk_create_document or uitk_set_document.
  • For generated starter layouts → use uitk_create_from_template.

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.

Common Mistakes

DO NOT (common hallucinations):

  • Requires Unity 2022.3+ — no package install needed; built into the engine
  • uitoolkit_create_button / uitoolkit_create_label do not exist -> use uitk_add_element
  • uitoolkit_set_style does not exist -> use uitk_add_uss_rule, uitk_remove_uss_rule, or uitk_modify_element
  • uitoolkit_create_canvas does not exist -> UI Toolkit uses UIDocument, not Canvas
  • uitk_* and ui_* 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

Quick Reference

File Skills

SkillUseKey parameters
uitk_create_ussCreate USS filesavePath, content?
uitk_create_uxmlCreate UXML filesavePath, content?, ussPath?
uitk_read_fileRead USS/UXML contentfilePath
uitk_write_fileOverwrite file contentfilePath, content
uitk_delete_fileDelete USS/UXML filefilePath
uitk_find_filesSearch files by name/pathtype?, folder?, filter?, limit?
uitk_create_batchCreate 2+ files in one callitems

Scene Skills

SkillUseKey parameters
uitk_create_documentCreate UIDocument GameObjectname, uxmlPath?, panelSettingsPath?, sortOrder?, parentName?/parentInstanceId?/parentPath?
uitk_set_documentChange UIDocument asset bindingsname/instanceId, uxmlPath?, panelSettingsPath?
uitk_create_panel_settingsCreate PanelSettings assetsavePath, scaleMode, referenceResolutionX/Y, Unity 6 world-space options
uitk_get_panel_settingsRead PanelSettings valuesassetPath
uitk_set_panel_settingsUpdate PanelSettings selectivelyassetPath, changed fields only
uitk_list_documentsList scene UIDocumentsnone
uitk_inspect_documentInspect live VisualElement treename/instanceId/path, depth

UXML Structure Skills

SkillUseKey parameters
uitk_add_elementAdd a child elementfilePath, elementType, parentName?, elementName?, text?, classes?
uitk_remove_elementRemove by namefilePath, elementName
uitk_modify_elementChange attributes/classes/textfilePath, elementName, text?, classes?, style?, newName?, bindingPath?, custom attribute fields
uitk_clone_elementDuplicate an element subtreefilePath, elementName, newName?
uitk_inspect_uxmlParse UXML hierarchyfilePath, depth?

USS Style Skills

SkillUseKey parameters
uitk_add_uss_ruleAdd or replace selector rulefilePath, selector, properties
uitk_remove_uss_ruleRemove selector rulefilePath, selector
uitk_list_uss_variablesInspect design tokens / var() usagefilePath

Template and CodeGen Skills

SkillUseKey parameters
uitk_create_from_templateGenerate paired UXML+USStemplate, savePath, name?
uitk_create_editor_windowGenerate EditorWindow scriptsavePath, className, uxmlPath?, ussPath?, menuPath?
uitk_create_runtime_uiGenerate runtime MonoBehaviour query scaffoldsavePath, className, elementQueries?

Supported starter templates include menu, hud, dialog, settings, inventory, list, tab-view, toolbar, card, and notification.

Core Domain Knowledge

USS vs CSS

PatternSupported in USSWhat to do
Flex layoutYesUse flex-direction, flex-wrap, align-items, justify-content
border-radius, opacity, overflow:hiddenYesSafe to use
Transforms / transitionsYestranslate, scale, rotate work
CSS variablesYesPrefer :root tokens
display:grid / display:block / display:inlineNoEverything is flex; emulate grids with wrapping rows
box-shadowNoFake with nested background element
linear-gradient() / radial-gradient()NoUse image textures
calc() / @mediaNoUse explicit values + PanelSettings.scaleMode
::before / ::afterNoAdd a real child VisualElement
z-indexNoLater siblings render on top

Common USS workarounds

NeedUSS-safe workaround
ShadowExtra child VisualElement behind content
Responsive scalingPanelSettings.scaleMode = ScaleWithScreenSize
Grid cardsflex-direction: row + flex-wrap: wrap + child widths
Circular avatarEqual width/height + radius = half size + overflow:hidden
Pseudo decorationAdd an extra absolutely positioned child

High-Frequency Parameters

SkillParameters you usually need first
uitk_create_panel_settingssavePath, scaleMode, referenceResolutionX, referenceResolutionY
uitk_create_documentname, uxmlPath, panelSettingsPath, sortOrder?
uitk_add_elementfilePath, elementType, parentName?, elementName?, text?, classes?
uitk_modify_elementfilePath, elementName, changed attributes only
uitk_add_uss_rulefilePath, selector, properties

PanelSettings choices

  • ScaleWithScreenSize: default for runtime HUD/menu UI
  • ConstantPixelSize: use when strict pixel mapping matters
  • ConstantPhysicalSize: 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_uxml before complex structural edits if you did not create the file yourself.
  • uitk_create_uxml can auto-reference a stylesheet when ussPath is provided.

Workflow Notes

  1. Create USS/UXML first, then attach them through uitk_create_document.
  2. Runtime rendering needs a valid PanelSettings asset.
  3. When USS and UXML are in the same folder, prefer <Style src="MyStyle.uss" />; use a full asset path only for cross-folder references.
  4. Start with design tokens, then component rules, then layout containers.
  5. For incremental edits, prefer uitk_read_file -> edit -> uitk_write_file.
  6. When creating 2+ files, use uitk_create_batch.
  7. Unity 6 world-space rendering uses PanelSettings world-space options plus the scene-side UIDocument camera setup.
  8. Use uitk_create_from_template when the user needs a starter screen fast; use uitk_add_element / uitk_add_uss_rule for targeted edits on existing files.

Design Token Starter (:root)

:root {
    --color-primary: #E8632B;
    --color-primary-dark: #C9521D;
    --color-secondary: #2B7DE8;
    --color-bg: #FFF8F0;
    --color-surface: #FFFFFF;
    --color-text: #1A1A1A;
    --color-muted: #666666;
    --color-border: #E0E0E0;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --font-md: 14px;
    --font-lg: 18px;
}

UXML Element Quick Reference

<engine:VisualElement name="root" class="my-class" />
<engine:ScrollView mode="Vertical" name="scroll" />
<engine:Button text="Click Me" name="btn" />
<engine:Label text="Hello World" name="my-label" />
<engine:TextField label="Name:" value="default" name="input" />
<engine:Toggle label="Enable" value="true" name="toggle" />
<engine:Slider label="Volume" low-value="0" high-value="1" value="0.8" />
<engine:DropdownField label="Quality" choices="Low,Medium,High" value="Medium" />
<engine:IntegerField label="Count" value="0" />
<Style src="MyStyle.uss" />

RunCommand Examples

Recipe path rule: ../../recipes/uitoolkit/<command>.md

See ../../recipes/uitoolkit/<command>.md for C# templates.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.