using System; using System.Collections.Generic; using System.Threading.Tasks; using MCPForUnity.Editor.Clients; using MCPForUnity.Editor.Dependencies; using MCPForUnity.Editor.Dependencies.Models; using MCPForUnity.Editor.Helpers; using MCPForUnity.Editor.Services; using MCPForUnity.Editor.Windows.Components.Branding; using UnityEditor; using UnityEngine; using UnityEngine.UIElements; namespace MCPForUnity.Editor.Windows { /// /// Setup window for checking and guiding dependency installation /// public class MCPSetupWindow : EditorWindow { // UI Elements private VisualElement pythonIndicator; private Label pythonVersion; private Label pythonDetails; private VisualElement uvIndicator; private Label uvVersion; private Label uvDetails; private Label statusMessage; private VisualElement installationSection; private Label installationInstructions; private Button openPythonLinkButton; private Button openUvLinkButton; private Button installUvButton; private Button refreshButton; private Button doneButton; // Tracks an in-flight uv install so completion is handled on the main thread. private Task _uvInstallTask; // Step 2 (Configure Clients) UI elements private VisualElement stepDeps; private VisualElement stepClients; private VisualElement clientsList; private Button skipClientsButton; private Button configureSelectedButton; private readonly List<(IMcpClientConfigurator client, Toggle toggle)> clientToggles = new(); private DependencyCheckResult _dependencyResult; public static void ShowWindow(DependencyCheckResult dependencyResult = null) { var window = GetWindow("MCP Setup"); window.minSize = new Vector2(480, 320); window._dependencyResult = dependencyResult ?? DependencyManager.CheckAllDependencies(); window.Show(); } public void CreateGUI() { string basePath = AssetPathUtility.GetMcpPackageRootPath(); // Load UXML var visualTree = AssetDatabase.LoadAssetAtPath( $"{basePath}/Editor/Windows/MCPSetupWindow.uxml" ); if (visualTree == null) { McpLog.Error($"Failed to load UXML at: {basePath}/Editor/Windows/MCPSetupWindow.uxml"); return; } visualTree.CloneTree(rootVisualElement); // Embed the Ocean brand mark beside the title var setupHeader = rootVisualElement.Q("setup-header"); if (setupHeader != null && setupHeader.Q() == null) { var logo = new OceanMark { name = "setup-logo" }; logo.AddToClassList("setup-logo"); setupHeader.Insert(0, logo); } // Cache UI elements pythonIndicator = rootVisualElement.Q("python-indicator"); pythonVersion = rootVisualElement.Q