@@ -261,24 +261,27 @@ public void CreateGUI()
261261
262262 McpPlugin . McpPlugin . DoAlways ( plugin =>
263263 {
264- Observable . Interval ( TimeSpan . FromSeconds ( 1 ) )
264+ var toolManager = plugin . McpManager . ToolManager ;
265+ if ( toolManager == null )
266+ {
267+ toolsStatusLabel . text = "Total tools (0), active tools (0), disabled tools (0)" ;
268+ return ;
269+ }
270+
271+ void UpdateStats ( )
272+ {
273+ var allTools = toolManager . GetAllTools ( ) ;
274+ var total = allTools . Count ( ) ;
275+ var active = allTools . Count ( t => toolManager . IsToolEnabled ( t . Name ) ) ;
276+ var disabled = total - active ;
277+ toolsStatusLabel . text = $ "Total tools ({ total } ), active tools ({ active } ), disabled tools ({ disabled } )";
278+ }
279+
280+ UpdateStats ( ) ;
281+
282+ toolManager . OnToolsUpdated
265283 . ObserveOnCurrentSynchronizationContext ( )
266- . Subscribe ( _ =>
267- {
268- var toolManager = UnityMcpPlugin . Instance . McpPluginInstance ? . McpManager . ToolManager ;
269- if ( toolManager != null )
270- {
271- var allTools = toolManager . GetAllTools ( ) . ToList ( ) ;
272- var total = allTools . Count ;
273- var active = allTools . Count ( t => toolManager . IsToolEnabled ( t . Name ) ) ;
274- var disabled = total - active ;
275- toolsStatusLabel . text = $ "Total tools ({ total } ), active tools ({ active } ), disabled tools ({ disabled } )";
276- }
277- else
278- {
279- toolsStatusLabel . text = "Total tools (0), active tools (0), disabled tools (0)" ;
280- }
281- } )
284+ . Subscribe ( _ => UpdateStats ( ) )
282285 . AddTo ( _disposables ) ;
283286 } ) . AddTo ( _disposables ) ;
284287
0 commit comments