Token导航 LogoToken导航

Agent Skill · 前端设计

unity-ui(Unity UI 浏览器)

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化。它适合让 Agent 根据产品场景整理页面结构、生成 UI 方案、检查视觉一致性或改进组件层级。使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。

unity-ui 是前端设计类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在前端设计类的 10,216 个 Skill 里排第 8,105。

总安装 315周安装 13GitHub Stars 14下载 103核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:unity-ui(Unity UI 浏览器)
来源仓库:https://github.com/nice-wolf-studio/unity-claude-skills
仓库路径:skills/unity-ui
安装命令:
npx skills add https://github.com/nice-wolf-studio/unity-claude-skills --skill unity-ui
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/nice-wolf-studio/unity-claude-skills --skill unity-ui

这个 Skill 是做什么的

前端设计类 Skill 关注页面结构、视觉规范和组件写法,输出通常是可运行的界面代码。

用于辅助界面设计、视觉规范和交互体验优化。unity-ui 属于前端设计类 Skill,可作为该场景下的辅助能力补充。适用于 Unity 游戏界面结构整理和组件层级改进。需结合品牌规范和用户任务,避免堆砌装饰元素。安装方式:通过 GitHub 仓库安装,使用前确认权限与维护状态。

涉及真实页面改动时,建议用截图或预览检查文本溢出和对齐。

来源仓库内路径:skills/unity-ui

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/nice-wolf-studio/unity-claude-skills --skill u…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

unity-ui 怎么安装?

在终端执行 npx skills add https://github.com/nice-wolf-studio/unity-claude-skills --skill unity-ui。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

unity-ui 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

unity-ui 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

unity-ui 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

unity-ui 用的人多吗?

公开数据是累计安装 315 次,近一周安装 13 次,下载 103 次,GitHub 14 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

unity-ui 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理前端设计类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

前端设计类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
frontend-design

前端设计 · Codex、Claude

8,823,360126,072只读MIT通过
vercel-composition-patterns

Vercel 组合模式 · Codex、Claude

3,858,81625,893需要联网MIT通过
vercel-react-native-skills

Vercel React native skills 前端 · Codex、Claude

2,468,66425,878只读MIT通过
adapt

adapt 搜索 · Codex、Claude

2,027,04023,125操作浏览器未明确通过
bolder

bolder 分析 · Codex、Claude

2,004,28823,130只读未明确通过
unity-ui

Unity UI 浏览器 · 本页

31514只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Unity UI Systems

Unity provides three UI frameworks. UI Toolkit is the recommended system for new projects. uGUI remains supported for legacy and certain runtime use cases. IMGUI is strictly for Editor tooling and debugging.

UI System Comparison

FeatureUI ToolkituGUI (Canvas)IMGUI
Recommended for new projectsYesNo (legacy)No
Runtime game UIYesYesNot recommended
Editor extensionsYesNoYes
ApproachWeb-inspired (UXML + USS + C#)GameObject + ComponentCode-only (OnGUI)
Layout systemFlexbox (Yoga)RectTransform + AnchorsImmediate mode
StylingUSS stylesheetsPer-component propertiesGUIStyle / GUISkin
Visual authoringUI BuilderScene ViewNone
PerformanceOptimized retained modeCanvas batchingRedraws every frame
Data bindingSerializedObject + Runtime bindingManual via codeManual via code
World-space UISupportedCanvas World Space modeNot supported
Input integrationPointer/Keyboard eventsEventSystem + RaycastersEvent.current

Decision guide:

  • New runtime UI (menus, HUD, inventory) --> UI Toolkit
  • New Editor windows / inspectors --> UI Toolkit
  • Existing project with uGUI --> Continue with uGUI, migrate incrementally
  • Quick debug overlays in Editor --> IMGUI
  • World-space UI on 3D objects --> Either UI Toolkit or uGUI World Space Canvas

UI Toolkit

UI Toolkit is Unity's modern UI framework inspired by web technologies. It uses UXML for structure, USS for styling, and C# for logic.

Core Architecture

UIDocument (MonoBehaviour on GameObject)
  --> VisualTreeAsset (.uxml)  -- defines structure
  --> StyleSheet (.uss)         -- defines appearance
  --> C# script                 -- defines behavior

All UI elements inherit from VisualElement. The root is accessed via rootVisualElement.

UXML Structure

UXML defines the UI hierarchy declaratively:

<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
    <ui:Style src="MainMenu.uss" />
    <ui:VisualElement name="root-container" class="container">
        <ui:Label text="Game Menu" class="title" />
        <ui:Button text="Play" name="play-button" class="menu-btn" />
        <ui:Button text="Settings" name="settings-button" class="menu-btn" />
        <ui:Toggle label="Fullscreen" name="fullscreen-toggle" />
        <ui:Slider label="Volume" low-value="0" high-value="100" name="volume-slider" />
        <ui:TextField label="Player Name" name="player-name" />
    </ui:VisualElement>
</ui:UXML>

Key points:

  • xmlns:ui="UnityEngine.UIElements" is the standard namespace
  • Reference USS files with <ui:Style src="..." />
  • Use name attribute for C# queries, class for USS styling
  • Templates can be imported: <ui:Template src="other.uxml" name="other" />

USS Styling

USS uses CSS-like syntax with Unity-specific extensions. All USS properties use the prefix -unity- for Unity-specific features.

/* Type selector */
Button {
    background-color: #2D2D2D;
    border-radius: 4px;
    padding: 8px 16px;
    -unity-font-style: bold;
}

/* Class selector */
.menu-btn {
    width: 200px;
    height: 40px;
    margin: 4px 0;
    font-size: 16px;
    color: #FFFFFF;
}

/* Name selector */
#play-button {
    background-color: #4CAF50;
}

/* Pseudo-class */
.menu-btn:hover {
    background-color: #555555;
    scale: 1.05 1.05;
}

.menu-btn:active {
    background-color: #333333;
}

.menu-btn:disabled {
    opacity: 0.5;
}

/* Descendant selector */
.container > Label {
    -unity-text-align: middle-center;
}

/* USS variables */
:root {
    --primary-color: #4CAF50;
    --font-large: 24px;
}

.title {
    color: var(--primary-color);
    font-size: var(--font-large);
}

Selector types: Type (Button), Name (#name), Class (.class), Universal (*), Descendant (A B), Child (A > B), Multiple (A.class), Pseudo-classes (:hover, :active, :focus, :disabled, :checked).

Layout is Flexbox-based: Use flex-direction, flex-grow, flex-shrink, justify-content, align-items, align-self, flex-wrap. Default direction is column.

C# Setup and Interaction

using UnityEngine;
using UnityEngine.UIElements;

public class MainMenuController : MonoBehaviour
{
    [SerializeField] private UIDocument uiDocument;

    private Button playButton;
    private Button settingsButton;
    private Toggle fullscreenToggle;
    private Slider volumeSlider;
    private TextField playerNameField;

    private void OnEnable()
    {
        var root = uiDocument.rootVisualElement;

        // Query single elements by name
        playButton = root.Q<Button>("play-button");
        settingsButton = root.Q<Button>("settings-button");
        fullscreenToggle = root.Q<Toggle>("fullscreen-toggle");
        volumeSlider = root.Q<Slider>("volume-slider");
        playerNameField = root.Q<TextField>("player-name");

        // Register click callbacks
        playButton.RegisterCallback<ClickEvent>(OnPlayClicked);
        settingsButton.RegisterCallback<ClickEvent>(OnSettingsClicked);

        // Register value change callbacks
        fullscreenToggle.RegisterValueChangedCallback(OnFullscreenChanged);
        volumeSlider.RegisterValueChangedCallback(OnVolumeChanged);

        // Query multiple elements by class
        var allButtons = root.Query<Button>(className: "menu-btn").ToList();
    }

    private void OnDisable()
    {
        playButton.UnregisterCallback<ClickEvent>(OnPlayClicked);
        settingsButton.UnregisterCallback<ClickEvent>(OnSettingsClicked);
        fullscreenToggle.UnregisterValueChangedCallback(OnFullscreenChanged);
        volumeSlider.UnregisterValueChangedCallback(OnVolumeChanged);
    }

    private void OnPlayClicked(ClickEvent evt) => Debug.Log("Play clicked");
    private void OnSettingsClicked(ClickEvent evt) => Debug.Log("Settings clicked");

    private void OnFullscreenChanged(ChangeEvent<bool> evt)
    {
        Screen.fullScreen = evt.newValue;
    }

    private void OnVolumeChanged(ChangeEvent<float> evt)
    {
        AudioListener.volume = evt.newValue / 100f;
    }
}

Programmatic UI creation (no UXML):

private void CreateUIFromCode()
{
    var root = uiDocument.rootVisualElement;

    var container = new VisualElement();
    container.AddToClassList("container");
    root.Add(container);

    var label = new Label("Created from C#");
    container.Add(label);

    var button = new Button(() => Debug.Log("Clicked")) { text = "Click Me" };
    button.name = "dynamic-button";
    container.Add(button);
}

Event System

UI Toolkit events propagate in two phases:

  1. Trickle-down -- from root to target element
  2. Bubble-up -- from target back to root
// Default: bubble-up phase
element.RegisterCallback<PointerDownEvent>(OnPointerDown);

// Trickle-down phase (parent reacts before children)
element.RegisterCallback<PointerDownEvent>(OnPointerDown, TrickleDown.TrickleDown);

// Pass custom data to callbacks
element.RegisterCallback<ClickEvent, string>(OnClickWithData, "my-data");

// Set value without triggering ChangeEvent
myControl.SetValueWithoutNotify(newValue);

Data Binding

SerializedObject binding (Editor / Inspector UI):

// In UXML: <ui:IntegerField binding-path="m_Health" label="Health" />
// In C#:
var healthField = new IntegerField("Health") { bindingPath = "m_Health" };
root.Add(healthField);
root.Bind(new SerializedObject(targetComponent));

Bindable objects: MonoBehaviour, ScriptableObject, native Unity types, primitives. Only the value property of INotifyValueChanged elements can be bound.

Runtime binding connects plain C# objects to UI controls, works in both Editor and runtime contexts. Set data sources on elements and define binding modes for synchronization direction.

See: references/ui-data-binding.md

Manipulators

Manipulators encapsulate event-handling logic, separating interaction from UI code:

public class DragManipulator : PointerManipulator
{
    private Vector3 startPosition;
    private bool isDragging;

    public DragManipulator(VisualElement target)
    {
        this.target = target;
    }

    protected override void RegisterCallbacksOnTarget()
    {
        target.RegisterCallback<PointerDownEvent>(OnPointerDown);
        target.RegisterCallback<PointerMoveEvent>(OnPointerMove);
        target.RegisterCallback<PointerUpEvent>(OnPointerUp);
    }

    protected override void UnregisterCallbacksFromTarget()
    {
        target.UnregisterCallback<PointerDownEvent>(OnPointerDown);
        target.UnregisterCallback<PointerMoveEvent>(OnPointerMove);
        target.UnregisterCallback<PointerUpEvent>(OnPointerUp);
    }

    private void OnPointerDown(PointerDownEvent evt)
    {
        startPosition = evt.position;
        isDragging = true;
        target.CapturePointer(evt.pointerId);
        evt.StopPropagation();
    }

    private void OnPointerMove(PointerMoveEvent evt)
    {
        if (!isDragging) return;
        var delta = evt.position - startPosition;
        target.transform.position += (Vector3)delta;
        startPosition = evt.position;
    }

    private void OnPointerUp(PointerUpEvent evt)
    {
        isDragging = false;
        target.ReleasePointer(evt.pointerId);
        evt.StopPropagation();
    }
}

// Usage:
myElement.AddManipulator(new DragManipulator(myElement));

Built-in manipulator classes: Manipulator (base), PointerManipulator, MouseManipulator, Clickable, ContextualMenuManipulator, KeyboardNavigationManipulator.

Custom Controls

// Unity 6+ recommended pattern: [UxmlElement] attribute (replaces deprecated UxmlFactory/UxmlTraits)
[UxmlElement]
public partial class HealthBar : VisualElement
{
    [UxmlAttribute]
    public float MaxHealth { get; set; } = 100f;

    private VisualElement fillBar;
    private float currentHealth;

    public float CurrentHealth
    {
        get => currentHealth;
        set
        {
            currentHealth = Mathf.Clamp(value, 0, MaxHealth);
            fillBar.style.width = Length.Percent(currentHealth / MaxHealth * 100f);
        }
    }

    public HealthBar()
    {
        AddToClassList("health-bar");
        fillBar = new VisualElement();
        fillBar.AddToClassList("health-bar__fill");
        Add(fillBar);
    }
}

uGUI / Canvas System (Legacy)

uGUI is Unity's older GameObject-based UI system. It uses Canvas, RectTransform, and the EventSystem.

Canvas Render Modes

ModeDescriptionUse Case
Screen Space - OverlayRenders on top of everything, scales with screenStandard HUD, menus
Screen Space - CameraRendered by a specific camera, affected by perspectiveUI with depth effects
World SpaceCanvas as a 3D object in the sceneIn-world displays, VR UI

Core Components

Visual: Text, Image, RawImage Interaction: Button, Toggle, ToggleGroup, Slider, Scrollbar, Dropdown, InputField, ScrollRect Layout: HorizontalLayoutGroup, VerticalLayoutGroup, GridLayoutGroup, ContentSizeFitter, AspectRatioFitter, LayoutElement

RectTransform and Anchoring

All uGUI elements use RectTransform instead of Transform. Anchors define how an element positions relative to its parent:

  • Anchor Min/Max as fractions (0.0 = left/bottom, 1.0 = right/top)
  • Together anchors: fixed position (Pos X, Pos Y, Width, Height)
  • Separated anchors: stretching (Left, Right, Top, Bottom padding)
  • Pivot: center point for rotation and scaling

uGUI Example

using UnityEngine;
using UnityEngine.UI;

public class MenuManager : MonoBehaviour
{
    [SerializeField] private Button playButton;
    [SerializeField] private Slider volumeSlider;
    [SerializeField] private Toggle muteToggle;

    private void OnEnable()
    {
        playButton.onClick.AddListener(OnPlayClicked);
        volumeSlider.onValueChanged.AddListener(OnVolumeChanged);
        muteToggle.onValueChanged.AddListener(OnMuteToggled);
    }

    private void OnDisable()
    {
        playButton.onClick.RemoveListener(OnPlayClicked);
        volumeSlider.onValueChanged.RemoveListener(OnVolumeChanged);
        muteToggle.onValueChanged.RemoveListener(OnMuteToggled);
    }

    private void OnPlayClicked() => Debug.Log("Play");
    private void OnVolumeChanged(float value) => AudioListener.volume = value;
    private void OnMuteToggled(bool muted) => AudioListener.pause = muted;
}

Draw Order

Elements render in Hierarchy order: first child drawn first, last child drawn on top. Reorder with Transform.SetAsFirstSibling(), SetAsLastSibling(), SetSiblingIndex().

See: references/ugui-legacy.md


Anti-Patterns

Anti-PatternProblemCorrect Approach
Using inline styles everywherePer-element memory overheadUse USS files for shared styles
Universal selectors in complex USS (A * B)Poor selector performance at scaleUse BEM class naming, child selectors
Heavy :hover on elements with many descendantsMouse movement invalidates entire hierarchiesLimit :hover to leaf elements
Calling Bind() inside CreateInspectorGUI()Double-binding, automatic binding occurs after returnLet auto-binding handle it, or call Bind only on manually created UI
Rebuilding entire UI every frameDefeats retained-mode benefitsUpdate only changed elements
Multiple Canvases with dynamic content (uGUI)Canvas rebuild batches on any child changeSplit static and dynamic UI into separate Canvases
Not unregistering callbacksMemory leaks, stale referencesAlways unregister in OnDisable or OnDestroy
Using IMGUI for runtime game UIRedraws every frame, poor performanceUse UI Toolkit or uGUI
Forgetting EventSystem in scene (uGUI)No input events processedEnsure one EventSystem exists in scene

Key API Quick Reference

UI Toolkit

APIPurpose
UIDocumentMonoBehaviour that hosts a VisualTreeAsset
rootVisualElementRoot of the visual tree
Q<T>("name")Query single element by name
Q<T>(className: "cls")Query single element by class
Query<T>().ToList()Query multiple elements
RegisterCallback<TEvent>(callback)Register event handler
UnregisterCallback<TEvent>(callback)Remove event handler
RegisterValueChangedCallback(callback)Listen for value changes
SetValueWithoutNotify(value)Set value silently
AddToClassList("class")Add USS class
RemoveFromClassList("class")Remove USS class
AddManipulator(manipulator)Attach event manipulator
style.display = DisplayStyle.NoneHide element
style.display = DisplayStyle.FlexShow element
VisualTreeAsset.Instantiate()Create instance from UXML
element.Bind(serializedObject)Bind to SerializedObject

uGUI

APIPurpose
CanvasRoot container for all uGUI elements
CanvasScalerControls UI scaling across resolutions
GraphicRaycasterEnables input detection on Canvas
EventSystemCentral input event dispatcher
RectTransformTransform with anchoring and sizing
Button.onClickUnityEvent for click
Toggle.onValueChangedUnityEvent for toggle change
Slider.onValueChangedUnityEvent for slider change
LayoutGroupAuto-layout for children

Related Skills

  • unity-foundations -- GameObject, Component, MonoBehaviour lifecycle
  • unity-scripting -- C# patterns, SerializeField, events
  • unity-input -- Input System integration with UI

TextMeshPro

For all text rendering, use TextMeshPro (TMP) — not legacy UI.Text. TMP uses SDF rendering for crisp text at any scale. Use TextMeshProUGUI for Canvas UI, TextMeshPro for 3D world text. Use SetText("Score: {0}", value) for zero-allocation updates. See references/textmeshpro.md for full API, rich text tags, font assets, and patterns.

Additional Resources

平台分布

Codex

32.97%
按下载量换算34

Claude

33.07%
按下载量换算34

Cursor

19.46%
按下载量换算20

Gemini CLI

9.28%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills