Skip to content

Commit 342bc50

Browse files
committed
## feat(editor): Enhance MCP Unity Editor UI and documentation. These changes aim to make the MCP Unity Editor more user-friendly, easier to configure, and better documented for developers.
Key changes include: - **Editor UI Enhancements:** Updated `McpUnityEditorWindow.cs` to include new sections for connected clients, npm executable path configuration, and direct buttons for configuring Windsurf, Claude Desktop, and Cursor IDEs. - **New Settings:** Added `NpmExecutablePath` to `McpUnitySettings.cs` to allow users to specify a custom npm executable path. - **Utility Functions:** Implemented new utility methods in `McpUtils.cs` for generating MCP configuration JSON, integrating with various IDEs, and running npm commands for server installation/building. - **Comprehensive Documentation:** Overhauled `README.md` and its localized versions (`README-ja.md`, `README_zh-CN.md`) with detailed features, installation steps, usage guides, debugging information, and an extensive FAQ section. - **Documentation Assets:** Added a new `docs/` directory containing images referenced in the updated README files.
1 parent cb5f0dd commit 342bc50

File tree

13 files changed

+838
-110
lines changed

13 files changed

+838
-110
lines changed

Editor/UnityBridge/McpUnityEditorWindow.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class McpUnityEditorWindow : EditorWindow
2222
private string _mcpConfigJson = "";
2323
private bool _tabsIndentationJson = false;
2424
private Vector2 _helpTabScrollPosition = Vector2.zero;
25+
private Vector2 _serverTabScrollPosition = Vector2.zero;
2526

2627
[MenuItem("Tools/MCP Unity/Server Window", false, 1)]
2728
public static void ShowWindow()
@@ -66,6 +67,7 @@ private void OnGUI()
6667

6768
private void DrawServerTab()
6869
{
70+
_serverTabScrollPosition = EditorGUILayout.BeginScrollView(_serverTabScrollPosition);
6971
EditorGUILayout.BeginVertical("box");
7072

7173
// Server status
@@ -275,15 +277,20 @@ private void DrawServerTab()
275277
}
276278
}
277279

278-
EditorGUILayout.EndVertical();
279-
280+
EditorGUILayout.Separator();
281+
EditorGUILayout.Separator();
282+
280283
EditorGUILayout.Space();
281284

282285
// Force Install Server button
283286
if (GUILayout.Button("Force Install Server", GUILayout.Height(30)))
284287
{
285288
McpUnityServer.Instance.InstallServer();
289+
McpLogger.LogInfo("MCP Unity Server installed successfully.");
286290
}
291+
292+
EditorGUILayout.EndVertical();
293+
EditorGUILayout.EndScrollView();
287294
}
288295

289296
private void DrawHelpTab()

Editor/UnityBridge/McpUnitySettings.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace McpUnity.Unity
1313
public class McpUnitySettings
1414
{
1515
// Constants
16-
public const string ServerVersion = "1.0.0";
16+
public const string ServerVersion = "1.1.1";
1717
public const string PackageName = "com.gamelovers.mcp-unity";
1818
public const int RequestTimeoutMinimum = 10;
1919

@@ -58,7 +58,6 @@ public static McpUnitySettings Instance
5858
private McpUnitySettings()
5959
{
6060
LoadSettings();
61-
VsCodeWorkspaceUtils.AddPackageCacheToWorkspace();
6261
}
6362

6463
/// <summary>

Editor/Utils/McpUtils.cs

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ public static string GetServerPath()
7373

7474
if (packageInfo != null && !string.IsNullOrEmpty(packageInfo.resolvedPath))
7575
{
76-
return Path.Combine(packageInfo.resolvedPath, "Server~");
76+
string serverPath = Path.Combine(packageInfo.resolvedPath, "Server~");
77+
78+
return CleanPathPrefix(serverPath);
7779
}
7880

7981
var assets = AssetDatabase.FindAssets("tsconfig");
@@ -82,18 +84,20 @@ public static string GetServerPath()
8284
{
8385
// Convert relative path to absolute path
8486
var relativePath = AssetDatabase.GUIDToAssetPath(assets[0]);
85-
return Path.GetFullPath(Path.Combine(Application.dataPath, "..", relativePath));
87+
string fullPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..", relativePath));
88+
89+
return CleanPathPrefix(fullPath);
8690
}
8791
if (assets.Length > 0)
8892
{
8993
foreach (var assetJson in assets)
9094
{
9195
string relativePath = AssetDatabase.GUIDToAssetPath(assetJson);
9296
string fullPath = Path.GetFullPath(Path.Combine(Application.dataPath, "..", relativePath));
93-
97+
9498
if(Path.GetFileName(Path.GetDirectoryName(fullPath)) == "Server~")
9599
{
96-
return Path.GetDirectoryName(fullPath);
100+
return CleanPathPrefix(Path.GetDirectoryName(fullPath));
97101
}
98102
}
99103
}
@@ -106,6 +110,20 @@ public static string GetServerPath()
106110
return errorString;
107111
}
108112

113+
/// <summary>
114+
/// Cleans the path prefix by removing a leading "~" character if present on macOS.
115+
/// </summary>
116+
/// <param name="path">The path to clean.</param>
117+
/// <returns>The cleaned path.</returns>
118+
private static string CleanPathPrefix(string path)
119+
{
120+
if (path.StartsWith("~"))
121+
{
122+
return path.Substring(1);
123+
}
124+
return path;
125+
}
126+
109127
/// <summary>
110128
/// Adds the MCP configuration to the Windsurf MCP config file
111129
/// </summary>

README-ja.md

Lines changed: 109 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,21 +113,25 @@ MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペー
113113

114114
## <a name="install-server"></a>インストール
115115

116-
このMCP Unityサーバーのインストールは複数ステップのプロセスです:
117-
118-
### ステップ1: Unityパッケージマネージャー経由でUnity MCPサーバーパッケージをインストール
119-
1. Unityパッケージマネージャーを開く(Window > Package Manager)
120-
2. 左上隅の"+"ボタンをクリック
121-
3. "Add package from git URL..."を選択
122-
4. 入力: `https://github.com/CoderGamester/mcp-unity.git`
123-
5. "Add"をクリック
124-
125-
![package manager](https://github.com/user-attachments/assets/a72bfca4-ae52-48e7-a876-e99c701b0497)
116+
> [!IMPORTANT]
117+
> **プロジェクトパスにスペースを含めることはできません**
118+
>
119+
> Unity プロジェクトのファイルパスに**スペースを含めない**ことが非常に重要です。
120+
> プロジェクトパスにスペースが含まれている場合、MCP クライアント(例:Cursor、Claude、Windsurf)は MCP Unity サーバーに接続できません。
121+
>
122+
> **例:**
123+
> -**動作します:** `C:\Users\YourUser\Documents\UnityProjects\MyAwesomeGame`
124+
> -**失敗します:** `C:\Users\Your User\Documents\Unity Projects\My Awesome Game`
125+
>
126+
> インストールを進める前に、プロジェクトがスペースを含まないパスにあることを確認してください。
126127
128+
このMCP Unityサーバーのインストールは複数ステップのプロセスです:
127129

128-
### ステップ2: Node.jsをインストール
130+
### ステップ1: Node.jsをインストール
129131
> MCP Unityサーバーを実行するには、コンピューターにNode.js 18以降がインストールされている必要があります:
130132
133+
![node](docs/node.jpg)
134+
131135
<details>
132136
<summary><span style="font-size: 1.1em; font-weight: bold;">Windows</span></summary>
133137

@@ -156,6 +160,15 @@ MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペー
156160
```
157161
</details>
158162

163+
### ステップ2: Unityパッケージマネージャー経由でUnity MCPサーバーパッケージをインストール
164+
1. Unityパッケージマネージャーを開く(Window > Package Manager)
165+
2. 左上隅の"+"ボタンをクリック
166+
3. "Add package from git URL..."を選択
167+
4. 入力: `https://github.com/CoderGamester/mcp-unity.git`
168+
5. "Add"をクリック
169+
170+
![package manager](https://github.com/user-attachments/assets/a72bfca4-ae52-48e7-a876-e99c701b0497)
171+
159172
### ステップ3: AI LLMクライアントを設定
160173

161174
<details open>
@@ -165,7 +178,7 @@ MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペー
165178
2. Tools > MCP Unity > Server Windowに移動
166179
3. 以下の画像のようにAI LLMクライアントの"Configure"ボタンをクリック
167180

168-
![image](https://github.com/user-attachments/assets/8d286e83-da60-40fa-bd6c-5de9a77c1820)
181+
![image](docs/configure.jpg)
169182

170183
4. 表示されるポップアップで設定インストールを確認
171184

@@ -215,6 +228,9 @@ MCP Unityサーバーを起動するには2つの方法があります:
215228
1. Unityエディターを開く
216229
2. Tools > MCP Unity > Server Windowに移動
217230
3. "Start Server"ボタンをクリック
231+
4. Open Claude Desktop or your AI Coding IDE (e.g. Cursor IDE, Windsurf IDE, etc.) and start executing Unity tools
232+
233+
![connect](https://github.com/user-attachments/assets/2e266a8b-8ba3-4902-b585-b220b11ab9a2)
218234

219235
### オプション2: コマンドラインから起動
220236
1. ターミナルまたはコマンドプロンプトを開く
@@ -262,3 +278,84 @@ MCP Unityサーバーを起動するには2つの方法があります:
262278
- Unity Technologies
263279
- Node.js
264280
- WebSocket-Sharp
281+
282+
## よくある質問
283+
284+
<details>
285+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unityとは何ですか?</span></summary>
286+
287+
MCP Unityは、Model Context Protocol(MCP)を使用して、Unityエディター環境をAIアシスタントLLMツールに接続する強力なブリッジです。
288+
289+
本質的に、MCP Unityは次のことを行います。
290+
- Unityエディターの機能(オブジェクトの作成、コンポーネントの変更、テストの実行など)を、AIが理解して使用できる「ツール」および「リソース」として公開します。
291+
- Unity内にWebSocketサーバーを、そしてMCPを実装するNode.jsサーバー(UnityへのWebSocketクライアントとして機能)を実行します。これにより、AIアシスタントはUnityにコマンドを送信し、情報を受け取ることができます。
292+
- AIアシスタントとの自然言語プロンプトを使用して、Unityプロジェクト内で複雑なタスクを実行できるようにし、開発ワークフローを大幅に加速します。
293+
294+
</details>
295+
296+
<details>
297+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unityを使用する理由は何ですか?</span></summary>
298+
299+
MCP Unityは、開発者、アーティスト、プロジェクトマネージャーにいくつかの魅力的な利点を提供します。
300+
301+
- **開発の加速:** AIプロンプトを使用して、反復的なタスクを自動化し、ボイラープレートコードを生成し、アセットを管理します。これにより、創造的で複雑な問題解決に集中する時間を確保できます。
302+
- **生産性の向上:** メニューを手動でクリックしたり、簡単な操作のためにスクリプトを作成したりすることなく、Unityエディターの機能と対話できます。AIアシスタントは、Unity内でのあなたの能力を直接拡張します。
303+
- **アクセシビリティの向上:** UnityエディターやC#スクリプトの深い複雑さにあまり慣れていないユーザーでも、AIのガイダンスを通じてプロジェクトに意味のある貢献や変更を行うことができます。
304+
- **シームレスな統合:** MCPをサポートするさまざまなAIアシスタントやIDEと連携するように設計されており、開発ツールキット全体でAIを活用する一貫した方法を提供します。
305+
- **拡張性:** プロトコルとツールセットは拡張可能です。プロジェクト固有またはUnityの機能をAIに公開するための新しいツールとリソースを定義できます。
306+
- **コラボレーションの可能性:** AIがチームメンバーが従来行っていたタスクを支援したり、プロジェクトの構造や操作をガイドすることで新しい開発者のオンボーディングを支援したりする新しいコラボレーション方法を促進します。
307+
308+
</details>
309+
310+
<details>
311+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unityは、今後登場するUnity 6.2のAI機能と比較してどうですか?</span></summary>
312+
313+
Unity 6.2では、以前のUnity Muse(テクスチャやアニメーション生成などの生成AI機能用)やUnity Sentis(Unityランタイムでニューラルネットワークを実行するため)を含む、新しい組み込みAIツールが導入される予定です。Unity 6.2はまだ完全にリリースされていないため、この比較は公開されている情報と予想される機能に基づいています。
314+
315+
- **焦点:**
316+
- **MCP Unity:** 主に**エディターの自動化と対話**に焦点を当てています。これにより、外部AI(LLMベースのコーディングアシスタントなど)がUnityエディター自体を*制御およびクエリ*して、シーン、アセット、プロジェクト設定を操作できます。これは、エディター内での*開発者のワークフロー*を強化することです。
317+
- **Unity 6.2 AI:**
318+
- エディター内でのコンテンツ作成(テクスチャ、スプライト、アニメーション、動作、スクリプトの生成)と、Unityエディターインターフェースに直接統合された一般的なタスクのAI支援を目的としています。
319+
- UnityのドキュメントとAPI構造に関するあらゆる質問に、Unity環境により正確なカスタマイズされた例で答えるための微調整されたモデル。
320+
- AIモデルの推論を実行する機能を追加し、NPCの動作、画像認識などの機能のために、事前にトレーニングされたニューラルネットワークを*ゲームまたはアプリケーション内*にデプロイして実行できるようにします。
321+
322+
- **ユースケース:**
323+
- **MCP Unity:** 「新しい3Dオブジェクトを作成し、名前を「Player」にし、Rigidbodyを追加して、質量を10に設定してください。」「すべてのプレイモードテストを実行してください。」「コンソールログのエラーを修正するよう依頼してください。」「カスタムメニュー項目「iOS用のビルドを準備」を実行し、発生する可能性のあるエラーを修正してください。」
324+
- **Unity 6.2 AI:** 「このマテリアルにSFテクスチャを生成してください。」「シーン内のすべてのツリーの位置を「forest」とタグ付けされたテレインゾーン内に配置するように更新してください。」「このキャラクターのアニメーションを作成してください。」「キャラクターを完成させるために2Dスプライトを生成してください。」「コンソールログのエラーの詳細を尋ねてください。」
325+
326+
- **補完的であり、相互排他的ではない:**
327+
MCP UnityとUnityのネイティブAIツールは補完的であると見なすことができます。AIコーディングアシスタントでMCP Unityを使用してシーンを設定したり、アセットを一括変更したりしてから、Unity AIツールを使用して特定のテクスチャを生成したり、アニメーションや2Dスライトをそれらのアセットの1つに作成したりすることができます。MCP Unityは、より広範な外部AIサービスと統合したり、カスタム自動化ワークフローを構築したりしたい開発者にとって強力な、プロトコルベースのエディターとの対話方法を提供します。
328+
329+
</details>
330+
331+
<details>
332+
<summary><span style="font-size: 1.1em; font-weight: bold;">現在、どのMCPホストとIDEがMCP Unityをサポートしていますか?</span></summary>
333+
334+
MCP Unityは、MCPクライアントとして機能できるAIアシスタントまたは開発環境と連携するように設計されています。エコシステムは成長していますが、現在の既知の統合または互換性のあるプラットフォームには以下が含まれます。
335+
- Windsurf
336+
- Cursor
337+
- GitHub Copilot
338+
- Claude Desktop
339+
340+
</details>
341+
342+
<details>
343+
<summary><span style="font-size: 1.1em; font-weight: bold;">プロジェクトにカスタムツールでMCP Unityを拡張できますか?</span></summary>
344+
345+
はい、もちろんです!MCP Unityアーキテクチャの重要な利点の1つは、その拡張性です。
346+
- **Unity内(C#):** `McpToolBase`(またはリソースの同様のベース)を継承する新しいC#クラスを作成して、カスタムUnityエディター機能を公開できます。これらのツールは、`McpUnityServer.cs`に登録されます。たとえば、プロジェクト固有のアセットインポートパイプラインを自動化するツールを作成できます。
347+
- **Node.jsサーバー内(TypeScript):** 次に、`Server/src/tools/`ディレクトリに対応するTypeScriptツールハンドラーを定義し、入力/出力のZodスキーマを含め、`Server/src/index.ts`に登録します。このNode.js部分は、新しいC#ツールへのリクエストをUnityに転送します。
348+
349+
これにより、AIの機能をゲームやアプリケーションの特定のニーズとワークフローに合わせて調整できます。
350+
351+
</details>
352+
353+
<details>
354+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unityは無料で利用できますか?</span></summary>
355+
356+
はい、MCP UnityはMITライセンスの下で配布されているオープンソースプロジェクトです。ライセンス条項に従って、自由に利用、変更、配布できます。
357+
358+
</details>
359+
360+
<details>
361+
<summary><span style="font-size: 1.1em; font-weight: bold;">MCP Unityに接続できないのはなぜですか?</span></summary>

0 commit comments

Comments
 (0)