Skip to content

Commit 942d249

Browse files
committed
refactor: rename manage_menu_item to execute_menu_item and update tool examples to use async/await
We'll eventually put a section for resources
1 parent 403713d commit 942d249

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README-zh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ MCP for Unity 作为桥梁,允许 AI 助手(如 Claude、Cursor)通过本
4545
* `manage_asset`: 执行资源操作(导入、创建、修改、删除等)。
4646
* `manage_shader`: 执行着色器 CRUD 操作(创建、读取、修改、删除)。
4747
* `manage_gameobject`: 管理游戏对象:创建、修改、删除、查找和组件操作。
48-
* `manage_menu_item`: 列出 Unity 编辑器菜单项;检查其存在性或执行它们(例如,执行"File/Save Project")。
48+
* `execute_menu_item`: 执行 Unity 编辑器菜单项(例如,执行"File/Save Project")。
4949
* `apply_text_edits`: 具有前置条件哈希和原子多编辑批次的精确文本编辑。
5050
* `script_apply_edits`: 结构化 C# 方法/类编辑(插入/替换/删除),具有更安全的边界。
5151
* `validate_script`: 快速验证(基本/标准)以在写入前后捕获语法/结构问题。

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ MCP for Unity acts as a bridge, allowing AI assistants (like Claude, Cursor) to
4545
* `manage_asset`: Performs asset operations (import, create, modify, delete, etc.).
4646
* `manage_shader`: Performs shader CRUD operations (create, read, modify, delete).
4747
* `manage_gameobject`: Manages GameObjects: create, modify, delete, find, and component operations.
48-
* `manage_menu_item`: List Unity Editor menu items; and check for their existence or execute them (e.g., execute "File/Save Project").
48+
* `execute_menu_item`: Executes Unity Editor menu items (e.g., "File/Save Project").
4949
* `apply_text_edits`: Precise text edits with precondition hashes and atomic multi-edit batches.
5050
* `script_apply_edits`: Structured C# method/class edits (insert/replace/delete) with safer boundaries.
5151
* `validate_script`: Fast validation (basic/standard) to catch syntax/structure issues before/after writes.

docs/CUSTOM_TOOLS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ from unity_connection import send_command_with_retry
2424
@mcp_for_unity_tool(
2525
description="My custom tool that does something amazing"
2626
)
27-
def my_custom_tool(
27+
async def my_custom_tool(
2828
ctx: Context,
2929
param1: Annotated[str, "Description of param1"],
3030
param2: Annotated[int, "Description of param2"] | None = None
3131
) -> dict[str, Any]:
32-
ctx.info(f"Processing my_custom_tool: {param1}")
32+
await ctx.info(f"Processing my_custom_tool: {param1}")
3333

3434
# Prepare parameters for Unity
3535
params = {
@@ -151,11 +151,11 @@ from unity_connection import send_command_with_retry
151151
@mcp_for_unity_tool(
152152
description="Capture screenshots in Unity, saving them as PNGs"
153153
)
154-
def capture_screenshot(
154+
async def capture_screenshot(
155155
ctx: Context,
156156
filename: Annotated[str, "Screenshot filename without extension, e.g., screenshot_01"],
157157
) -> dict[str, Any]:
158-
ctx.info(f"Capturing screenshot: {filename}")
158+
await ctx.info(f"Capturing screenshot: {filename}")
159159

160160
params = {
161161
"action": "capture",

0 commit comments

Comments
 (0)