Unity Plugin
通过约100个内置工具在Unity Editor中控制Unity。支持Editor与Play双模式。
连接方式
支持Telegram、Discord等OpenClaw通道:Unity启动时自动连接
配置路径:Window → OpenClaw Plugin → Settings
供Claude Code、Cursor等本地AI工具使用:
启动:Window → OpenClaw Plugin → MCP Bridge → Start
默认端口:27182
添加到Claude Code:
claude mcp add unity --node /MCP~/index.js
首次配置
若unity_execute工具不可用,请安装gateway扩展:
# 在skill目录下
./scripts/install-extension.sh
# 重启gateway
openclaw gateway restart
扩展文件位于extension/目录。
install-extension.sh作用
# 1. 将扩展文件从skill复制到gateway
# 源:/extension/
# 目标:~/.openclaw/extensions/unity/
# 2. 安装文件:
# - index.ts 扩展入口(HTTP处理器、工具)
# - package.json 扩展元数据
安装后重启gateway以加载扩展。
🔐 安全
本技能已设置disableModelInvocation: true,AI不会自动调用工具,仅执行用户明确请求的操作。修改方法见README.md。
速查表
核心工具
分类 关键工具
Scene scene.getActive, scene.getData, scene.load, scene.open, scene.save
GameObject gameobject.find, gameobject.getAll, gameobject.create, gameobject.destroy
Component component.get, component.set, component.add, component.remove
Transform transform.setPosition, transform.setRotation, transform.setScale
Debug debug.hierarchy, debug.screenshot, console.getLogs
Input input.clickUI, input.type, input.keyPress, input.mouseClick
Editor editor.getState, editor.play, editor.stop, editor.refresh
Material material.create, material.assign, material.modify, material.getInfo
Prefab prefab.create, prefab.instantiate, prefab.open, prefab.save
Asset asset.find, asset.copy, asset.move, asset.delete
Package package.add, package.remove, package.list, package.search
Test test.run, test.list, test.getResults
常用流程
unity_execute: debug.hierarchy {depth: 2}
unity_execute: scene.getActive
unity_execute: gameobject.find {name: "Player"}
unity_execute: component.get {name: "Player", componentType: "Transform"}
unity_execute: transform.setPosition {name: "Player", x: 0, y: 5, z: 0}
unity_execute: input.clickUI {name: "PlayButton"}
unity_execute: input.type {text: "TestUser", elementName: "UsernameInput"}
unity_execute: debug.screenshot
unity_execute: editor.play # 进入Play
unity_execute: editor.stop # 退出Play
unity_execute: editor.getState # 查看状态
unity_execute: editor.pause # 暂停
unity_execute: editor.unpause # 继续
unity_execute: material.create {name: "RedMetal", color: "#FF0000", metallic: 0.8}
unity_execute: material.assign {gameObjectName: "Player", materialPath: "Assets/Materials/RedMetal.mat"}
unity_execute: material.modify {path: "Assets/Materials/RedMetal.mat", metallic: 1.0, emission: "#FF4444"}
unity_execute: prefab.create {gameObjectName: "Player", path: "Assets/Prefabs/Player.prefab"}
unity_execute: prefab.instantiate {prefabPath: "Assets/Prefabs/Player.prefab", x: 0, y: 1, z: 0}
unity_execute: prefab.open {path: "Assets/Prefabs/Player.prefab"}
unity_execute: prefab.save
unity_execute: prefab.close
unity_execute: asset.find {query: "Player", type: "Prefab"}
unity_execute: asset.copy {sourcePath: "Assets/Prefabs/Player.prefab", destPath: "Assets/Backup/Player.prefab"}
unity_execute: asset.move {sourcePath: "Assets/Old/Item.prefab", destPath: "Assets/New/Item.prefab"}
unity_execute: package.list
unity_execute: package.search {query: "TextMeshPro"}
unity_execute: package.add {packageName: "com.unity.textmeshpro"}
unity_execute: package.add {gitUrl: "https://github.com/example/package.git"}
unity_execute: test.list {testMode: "EditMode"}
unity_execute: test.run {testMode: "EditMode", filter: "PlayerTests"}
unity_execute: test.getResults
# 日志
unity_execute: script.execute {code: "Debug.Log('Hello')"}
# 时间缩放
unity_execute: script.execute {code: "Time.timeScale = 0.5"}
# PlayerPrefs
unity_execute: script.execute {code: "PlayerPrefs.SetInt('score', 100)"}
# 反射调用
unity_execute: script.execute {code: "MyClass.MyMethod()"}
unity_execute: script.execute {code: "MyClass.MyStaticMethod('param1', 123)"}
工具分类(约100个)
Console(3个)
console.getLogs 获取日志(可过滤Log/Warning/Error)
console.getErrors 获取错误/异常日志(可选含警告)
console.clear 清空已捕获日志
Scene(7个)
scene.list 列出Build Settings中的场景
scene.getActive 获取当前激活场景