11using System ;
22using System . Collections . Generic ;
33using System . Threading . Tasks ;
4- using UnityEditor ;
5- using UnityEngine ;
6- using UnityEngine . UIElements ;
74using MCPForUnity . Editor . Helpers ;
85using MCPForUnity . Editor . Services ;
9- using MCPForUnity . Editor . Windows . Components . Settings ;
10- using MCPForUnity . Editor . Windows . Components . Connection ;
116using 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
1313namespace 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