Skip to content

Commit 01a3d47

Browse files
authored
Merge pull request CoplayDev#175 from dsarno/claude-code-button
feat: Add Claude Code support with register/unregister toggle button in Unity MCP window
2 parents a3b1319 + 92ad2c5 commit 01a3d47

File tree

4 files changed

+545
-50
lines changed

4 files changed

+545
-50
lines changed

UnityMcpBridge/Editor/Data/McpClients.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ public class McpClients
2828
configStatus = "Not Configured",
2929
},
3030
new()
31+
{
32+
name = "Claude Code",
33+
windowsConfigPath = Path.Combine(
34+
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
35+
".claude.json"
36+
),
37+
linuxConfigPath = Path.Combine(
38+
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
39+
".claude.json"
40+
),
41+
mcpType = McpTypes.ClaudeCode,
42+
configStatus = "Not Configured",
43+
},
44+
new()
3145
{
3246
name = "Cursor",
3347
windowsConfigPath = Path.Combine(

UnityMcpBridge/Editor/Models/McpTypes.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ public enum McpTypes
55
ClaudeDesktop,
66
Cursor,
77
VSCode,
8+
ClaudeCode,
89
}
910
}
1011

UnityMcpBridge/Editor/Windows/ManualConfigEditorWindow.cs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected virtual void OnGUI()
3939
);
4040
GUI.Label(
4141
new Rect(titleRect.x + 10, titleRect.y + 6, titleRect.width - 20, titleRect.height),
42-
mcpClient.name + " Manual Configuration",
42+
(mcpClient?.name ?? "Unknown") + " Manual Configuration",
4343
EditorStyles.boldLabel
4444
);
4545
EditorGUILayout.Space(10);
@@ -70,17 +70,17 @@ protected virtual void OnGUI()
7070
};
7171

7272
EditorGUILayout.LabelField(
73-
"1. Open " + mcpClient.name + " config file by either:",
73+
"1. Open " + (mcpClient?.name ?? "Unknown") + " config file by either:",
7474
instructionStyle
7575
);
76-
if (mcpClient.mcpType == McpTypes.ClaudeDesktop)
76+
if (mcpClient?.mcpType == McpTypes.ClaudeDesktop)
7777
{
7878
EditorGUILayout.LabelField(
7979
" a) Going to Settings > Developer > Edit Config",
8080
instructionStyle
8181
);
8282
}
83-
else if (mcpClient.mcpType == McpTypes.Cursor)
83+
else if (mcpClient?.mcpType == McpTypes.Cursor)
8484
{
8585
EditorGUILayout.LabelField(
8686
" a) Going to File > Preferences > Cursor Settings > MCP > Add new global MCP server",
@@ -96,16 +96,23 @@ protected virtual void OnGUI()
9696
// Path section with improved styling
9797
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
9898
string displayPath;
99-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
99+
if (mcpClient != null)
100100
{
101-
displayPath = mcpClient.windowsConfigPath;
102-
}
103-
else if (
104-
RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
105-
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
106-
)
107-
{
108-
displayPath = mcpClient.linuxConfigPath;
101+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
102+
{
103+
displayPath = mcpClient.windowsConfigPath;
104+
}
105+
else if (
106+
RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
107+
|| RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
108+
)
109+
{
110+
displayPath = mcpClient.linuxConfigPath;
111+
}
112+
else
113+
{
114+
displayPath = configPath;
115+
}
109116
}
110117
else
111118
{
@@ -224,7 +231,7 @@ protected virtual void OnGUI()
224231

225232
EditorGUILayout.Space(10);
226233
EditorGUILayout.LabelField(
227-
"3. Save the file and restart " + mcpClient.name,
234+
"3. Save the file and restart " + (mcpClient?.name ?? "Unknown"),
228235
instructionStyle
229236
);
230237

0 commit comments

Comments
 (0)