unity-skills
GitHub通过本地REST API自动化Unity编辑器,支持创建/修改GameObject、脚本、场景及资产。提供路由策略区分自动化操作与指导问答,涵盖预制体编辑、运行时场景执行及控制台历史等功能。
Trigger Scenarios
Install
npx skills add Besty0728/Unity-Skills --skill unity-skills -g -y
SKILL.md
Frontmatter
{
"name": "unity-skills",
"description": "Automate the Unity Editor through a local REST API — scripts, scenes, prefabs, assets, materials, lighting, tests and hundreds of other Editor operations. Use when the user wants to actually operate the Unity Editor from chat — create, modify or batch-edit GameObjects\/scripts\/scenes\/assets, or run Editor automation — in any language. Not needed for conceptual Unity Q&A that touches no Editor state — read the matching advisory doc under skills\/ instead. 当用户要从对话里实际操作 Unity 编辑器(创建\/修改\/批量编辑\/运行测试)时使用,任何语言均可触发;纯概念问答无需本协议。",
"compatibility": "Requires Unity Editor 2022.3+\/6000.x with the UnitySkills package (local REST server on localhost:8090-8100); Python 3 for the bundled client"
}
Unity Skills
Docs are English-only: match requests to modules by meaning in any language, and always reply in the user's language.
Route first
- Automate — the user asked you to act, or it needs traversal, search, batch, exact numbers or many objects: drive the Editor via REST.
- Guide — the user wants to do it themselves, or
surfaceProfileisguide: name menus and Inspector fields per SKILL_GUIDE.md. - Advise — a design question that changes nothing: answer from the matching advisory doc (scriptdesign, architecture, patterns, all in the module index), no REST calls.
Target the right Editor
Ports 8090–8100 go first come, first served: add ?expectProject=<project> (productName or folder name) or the exact ?expectInstance=<instanceId> to every write. A different Editor answers 409 INSTANCE_MISMATCH and runs nothing.
GET /health (exempt from the check) has currentMode, surfaceProfile, dryRunPolicy, instanceId: probe it once in the same shell command as your first request, adding no other call, then only after a refused write, 409, 503/refused connection or odd mode. bypass and auto run writes directly, but under auto confirm ≥5-object batches, prefab apply, scene-level, asset-overwriting or irreversible changes with the user first (probe alone before those); approval gates FullAuto writes behind single-shot grants (permanent: the user's Allowlist).
During a domain reload the port answers 503 or refuses for seconds while its ~/.unity_skills/registry.json entry reads reloading: retry it, never another instance.
Quick reference
Every skill is POST /skill/<name> with JSON args:
curl -s "http://localhost:<port>/skill/gameobject_set_transform?expectProject=<project>" -d '{"name":"Crate","posX":4,"posY":1.5,"posZ":-2}'
Target objects by name or the exact path/instanceId (likewise parentPath, childPath); skip lookup calls — a wrong name fails the call and returns candidates.
| Call |
|---|
gameobject_create {name, primitiveType, parentName, x,y,z, rotX,rotY,rotZ, scaleX,scaleY,scaleZ, space} — x/y/z, rot local to the parent unless space:"world"; scale local |
gameobject_set_transform {name, posX,posY,posZ, rotX,rotY,rotZ, scaleX,scaleY,scaleZ, localPosX,localPosY,localPosZ} — pos, rot world; scale, localPos local; omitted axes kept |
gameobject_find {name, useRegex, component} · gameobject_get_info {name} |
gameobject_rename {name, newName} · gameobject_duplicate {name} |
gameobject_set_parent {childName, parentName} · gameobject_set_active {name, active} |
gameobject_delete {name} (dryRun first) |
component_add {name, componentType} |
component_set_property {name, componentType, propertyName, value} — vectors, colours "1,2,3"; references referenceName/referencePath/assetPath |
component_get_properties {name, componentType} |
material_assign {name, materialPath} |
light_set_properties {name, r,g,b, intensity, range, spotAngle, shadows} |
script_create {scriptName, folder, content} — full source; dryRun first; wait below |
scene_save {} (dryRun first) |
Everything else: one discovery call
GET /skills/recommend?intent=<words>&includeSchema=true&topN=3&wire=v2 → top 3 skills with exact schemas (~1–4 KB); several needs → one more &intent=<words> each, same call. Name known → GET /skills/schema?names=a,b&wire=v2. Wider layers, v2 fields, constants → discovery.
Execute
Several steps, one call: POST /skills/batch?expectProject=<project> {"steps":[{"skill":"gameobject_create","args":{"name":"Rig"}},{"skill":"gameobject_create","args":{"name":"Arm","parentName":"Rig"}}]} — ≤50 steps; a step may name objects earlier steps created, or use {"$ref":"$0.instanceId"}; the first failure skips the rest unless continueOnError:true; ?mode=transactional = all-or-nothing → batch.
dryRun. If this table, recommend or schema gave you the signature this session, execute directly: a failed validation runs nothing and returns the dryRun report (all validation buckets, parameter list). DryRun first (?mode=dryRun&wire=v2) for deletes, riskLevel high, mayTriggerReload/mayEnterPlayMode, approval mode, non-transactional multi-step batches, or when unsure; under a dryRunPolicy, execute with the returned ?dryRunToken=. valid:true = no validation errors (warnings never block; the target may still be missing); authorization previews the permission gate.
Never invent skill or parameter names: use this table, recommend or schema. On failure read suggestedFixes; open a module doc only when a response names one.
Verify from the read-back
A successful write returns the state read back from the Editor (e.g. world position, valueSet) — that is the verification; resolutionNotes flags a non-exact name match. Use *_get_info only for async results or missing fields. Script writes, and asset_refresh after you write a .cs yourself (compileTriggered:true), return waitUrl: one GET waits out compile+reload → status:"completed", or failed with errors in resultData.compilation. One command:
u=http://localhost:<port>; c="$u/skill/script_create?expectProject=<project>"; b='{"scriptName":"Spin","content":"<source>"}'; s='{"steps":[{"skill":"component_add","args":{"name":"Crate","componentType":"Spin"}},{"skill":"component_set_property","args":{"name":"Crate","componentType":"Spin","propertyName":"speed","value":"9"}}]}'; curl -s "$c&mode=dryRun" -d "$b" | grep -q '"valid":true' && J=$(curl -s "$c" -d "$b" | tee /dev/stderr | grep -o '/jobs/[^"]*=90') && curl -s --retry 20 --retry-connrefused --retry-all-errors --retry-delay 2 "$u$J" && curl -s "$u/skills/batch?expectProject=<project>" -d "$s"
Surface profile and errors
surfaceProfile is the user's panel choice; guide and noSceneAuthoring hide some writes, which answer SURFACE_EXCLUDED naming the doc to read or the profile to leave. It is a boundary: do the rest of the task, never retry or route around it (profiles).
| Code | Meaning → action |
|---|---|
MISSING_PARAM / TARGET_NOT_FOUND |
Bad or unresolvable arguments → fix from details / locate the target (gameobject_find). |
INSTANCE_MISMATCH (409) |
Resend to the port suggestedFixes name. |
MISSING_PACKAGE |
Tell the user (dryRun missingPackages, recommend unavailable show it early); installing is their call. |
MODE_RESTRICTED / MODE_FORBIDDEN |
Grant / bypass or Allowlist → operating mode. |
| other | error codes |
Compile status, events, analytics → observability; closed Editor + opt-in Unity CLI → unity-cli.
Current snapshot: 839 REST skills, 56 source files, 54 categories, 83 module doc directories (54 REST/module docs + 29 advisory docs), Unity 2022.3+, default timeout 15 minutes.
Python helper: unity-skills/scripts/unity_skills.py
Version History
-
67cd2ca
Current 2026-10-18 21:37
新增预制体资产编辑、运行时场景调用、组件与方法发现调用、持久化控制台日志历史功能;优化编译证据绑定、主线程队列调度及Python客户端稳定性。
-
bbc65c7
2026-09-22 04:29
响应头新增 X-Unity-Instance/X-Unity-Project 以标识实例;SKILL.md 增加首次接触时确认 projectName 的检查步骤,解决多实例端口冲突导致的误操作问题。
-
2708bb6
2026-09-03 00:41
新增 QFramework 双轨支持(20个技能,纯反射零编译期依赖);全仓注释英化;修复 MODE_RESTRICTED 提示及计数错误。
-
8c31c5a
2026-08-27 12:42
新增addressables模块技能文档,修复审计发现的问题(如幽灵引用、授权流程错误),更新模板并同步协议引用。
-
5ee8388
2026-08-17 04:09
精简根文档至6.2KB,协议细节移至参考文件;新增引导模式文档及多个手动模块建议;为Top10 REST模块添加常见错误说明;版本号升级至2.6.0。
-
25d511e
2026-08-13 09:12
修正技能数量统计,将重复计数的 817 更正为实际注册的 784 个,同步更新相关文档与版本信息。
-
e49379b
2026-07-31 06:53
1. 新增会话首次接触的Health检查和Mode分支逻辑;2. 修复SKILL.md诱导Agent错误调用Python helper函数(如get_skill_schema)及存在25个幽灵Skill名的严重Bug;3. 更新SemiAuto模块清单为真实存在的Skill名;4. 优化Schema分层查询策略说明,强调缓存与压缩以减少Token消耗。
-
14e175d
2026-07-19 18:04
v2.1.1: 新增 PrimeTween Free 技能;修复 PackageInfo 二义性、FindType 复用及 .meta 补录问题,技能总数增至 738。v2.1.0: 引入分层 Schema 查询策略以优化成本,强化 dryRun 模式校验,替换宏控制为编辑器变更追踪。
- ec9f870 2026-07-05 14:38


