|
10 | 10 |
|
11 | 11 | #nullable enable |
12 | 12 | using System; |
| 13 | +using System.Linq; |
13 | 14 | using com.IvanMurzak.McpPlugin.Common; |
14 | 15 | using com.IvanMurzak.Unity.MCP.Runtime.Utils; |
15 | 16 | using Microsoft.AspNetCore.SignalR.Client; |
@@ -248,6 +249,42 @@ public void CreateGUI() |
248 | 249 | } |
249 | 250 | })); |
250 | 251 |
|
| 252 | + // Tools Configuration |
| 253 | + // ----------------------------------------------------------------- |
| 254 | + var btnOpenTools = root.Query<Button>("btnOpenTools").First(); |
| 255 | + btnOpenTools.RegisterCallback<ClickEvent>(evt => |
| 256 | + { |
| 257 | + McpToolsWindow.ShowWindow(); |
| 258 | + }); |
| 259 | + |
| 260 | + var toolsStatusLabel = root.Query<Label>("toolsStatusLabel").First(); |
| 261 | + |
| 262 | + McpPlugin.McpPlugin.DoAlways(plugin => |
| 263 | + { |
| 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 |
| 283 | + .ObserveOnCurrentSynchronizationContext() |
| 284 | + .Subscribe(_ => UpdateStats()) |
| 285 | + .AddTo(_disposables); |
| 286 | + }).AddTo(_disposables); |
| 287 | + |
251 | 288 | // Configure MCP Client |
252 | 289 | // ----------------------------------------------------------------- |
253 | 290 |
|
|
0 commit comments