Skip to content

Commit f6c6a3a

Browse files
fix: Reorder using directives and improve error logging format in MCP window
1 parent 9aea8e7 commit f6c6a3a

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Threading.Tasks;
4-
using UnityEditor;
5-
using UnityEngine;
6-
using UnityEngine.UIElements;
74
using MCPForUnity.Editor.Helpers;
85
using MCPForUnity.Editor.Services;
9-
using MCPForUnity.Editor.Windows.Components.Settings;
10-
using MCPForUnity.Editor.Windows.Components.Connection;
116
using MCPForUnity.Editor.Windows.Components.ClientConfig;
7+
using MCPForUnity.Editor.Windows.Components.Connection;
8+
using MCPForUnity.Editor.Windows.Components.Settings;
9+
using UnityEditor;
10+
using UnityEngine;
11+
using UnityEngine.UIElements;
1212

1313
namespace MCPForUnity.Editor.Windows
1414
{
@@ -53,6 +53,7 @@ public static void CloseAllOpenWindows()
5353
}
5454
}
5555
}
56+
5657
public void CreateGUI()
5758
{
5859
string basePath = AssetPathUtility.GetMcpPackageRootPath();
@@ -64,7 +65,9 @@ public void CreateGUI()
6465

6566
if (visualTree == null)
6667
{
67-
McpLog.Error($"Failed to load UXML at: {basePath}/Editor/Windows/MCPForUnityEditorWindow.uxml");
68+
McpLog.Error(
69+
$"Failed to load UXML at: {basePath}/Editor/Windows/MCPForUnityEditorWindow.uxml"
70+
);
6871
return;
6972
}
7073

@@ -105,8 +108,10 @@ public void CreateGUI()
105108
var settingsRoot = settingsTree.Instantiate();
106109
sectionsContainer.Add(settingsRoot);
107110
settingsSection = new McpSettingsSection(settingsRoot);
108-
settingsSection.OnGitUrlChanged += () => clientConfigSection?.UpdateManualConfiguration();
109-
settingsSection.OnHttpServerCommandUpdateRequested += () => connectionSection?.UpdateHttpServerCommandDisplay();
111+
settingsSection.OnGitUrlChanged += () =>
112+
clientConfigSection?.UpdateManualConfiguration();
113+
settingsSection.OnHttpServerCommandUpdateRequested += () =>
114+
connectionSection?.UpdateHttpServerCommandDisplay();
110115
}
111116

112117
// Load and initialize Connection section
@@ -118,7 +123,8 @@ public void CreateGUI()
118123
var connectionRoot = connectionTree.Instantiate();
119124
sectionsContainer.Add(connectionRoot);
120125
connectionSection = new McpConnectionSection(connectionRoot);
121-
connectionSection.OnManualConfigUpdateRequested += () => clientConfigSection?.UpdateManualConfiguration();
126+
connectionSection.OnManualConfigUpdateRequested += () =>
127+
clientConfigSection?.UpdateManualConfiguration();
122128
}
123129

124130
// Load and initialize Client Configuration section
@@ -190,11 +196,11 @@ private void ScheduleHealthCheck()
190196
{
191197
EditorApplication.delayCall += async () =>
192198
{
193-
if (this == null)
199+
if (this == null || connectionSection == null)
194200
{
195201
return;
196202
}
197-
await connectionSection?.VerifyBridgeConnectionAsync();
203+
await connectionSection.VerifyBridgeConnectionAsync();
198204
};
199205
}
200206
}

0 commit comments

Comments
 (0)