Skip to content

Commit c83c528

Browse files
committed
Add auto start option to the Editor settings to allow smooth running in some pcs when not necessary, or stop reconnection when the user is not online
1 parent fa9a009 commit c83c528

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

Editor/Resources/GetConsoleLogsResource.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ private void ClearLogs()
148148
{
149149
_logEntries.Clear();
150150
}
151-
152-
Debug.Log("[MCP Unity] Console logs cleared");
153151
}
154152
}
155153
}

Editor/UnityBridge/McpUnityEditorWindow.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ private void DrawServerTab()
107107

108108
EditorGUILayout.Space();
109109

110+
// Auto start server toggle
111+
bool autoStartServer = EditorGUILayout.Toggle(new GUIContent("Auto Start Server", "Automatically starts the MCP server when Unity opens"), settings.AutoStartServer);
112+
if (autoStartServer != settings.AutoStartServer)
113+
{
114+
settings.AutoStartServer = autoStartServer;
115+
settings.SaveSettings();
116+
}
117+
118+
EditorGUILayout.Space();
119+
110120
// Server control buttons
111121
EditorGUILayout.BeginHorizontal();
112122

Editor/UnityBridge/McpUnityServer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ private McpUnityServer()
7676
RegisterTools();
7777

7878
Debug.Log($"[MCP Unity] Created WebSocket server on port {McpUnitySettings.Instance.Port}");
79-
80-
StartServer();
79+
80+
if (McpUnitySettings.Instance.AutoStartServer || Application.internetReachability != NetworkReachability.NotReachable)
81+
{
82+
StartServer();
83+
}
8184
}
8285

8386
/// <summary>

Editor/UnityBridge/McpUnitySettings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class McpUnitySettings
2222
// Server settings
2323
public int Port { get; set; } = 8090;
2424

25+
[Tooltip("Whether to automatically start the MCP server when Unity opens")]
26+
public bool AutoStartServer = true;
27+
2528
/// <summary>
2629
/// Singleton instance of settings
2730
/// </summary>

0 commit comments

Comments
 (0)