Skip to content

Commit f8bc576

Browse files
committed
Address CodeRabbit feedback: use McpLog.Warn and guard against repeated CreateGUI calls
1 parent f6c6a3a commit f8bc576

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class MCPForUnityEditorWindow : EditorWindow
2020
private McpClientConfigSection clientConfigSection;
2121

2222
private static readonly HashSet<MCPForUnityEditorWindow> OpenWindows = new();
23+
private bool guiCreated = false;
2324

2425
public static void ShowWindow()
2526
{
@@ -49,13 +50,17 @@ public static void CloseAllOpenWindows()
4950
}
5051
catch (Exception ex)
5152
{
52-
Debug.LogWarning($"Error closing MCP window: {ex.Message}");
53+
McpLog.Warn($"Error closing MCP window: {ex.Message}");
5354
}
5455
}
5556
}
5657

5758
public void CreateGUI()
5859
{
60+
// Guard against repeated CreateGUI calls (e.g., domain reloads)
61+
if (guiCreated)
62+
return;
63+
5964
string basePath = AssetPathUtility.GetMcpPackageRootPath();
6065

6166
// Load main window UXML
@@ -138,6 +143,8 @@ public void CreateGUI()
138143
clientConfigSection = new McpClientConfigSection(clientConfigRoot);
139144
}
140145

146+
guiCreated = true;
147+
141148
// Initial updates
142149
RefreshAllData();
143150
}
@@ -152,6 +159,7 @@ private void OnDisable()
152159
{
153160
EditorApplication.update -= OnEditorUpdate;
154161
OpenWindows.Remove(this);
162+
guiCreated = false;
155163
}
156164

157165
private void OnFocus()

0 commit comments

Comments
 (0)