From e42612fa6349a96a7689723ed12cae5cae9f7265 Mon Sep 17 00:00:00 2001 From: Marcus Sanatan Date: Mon, 6 Oct 2025 17:48:24 -0400 Subject: [PATCH 01/43] First pass at new UI --- .../Windows/MCPForUnityEditorWindowNew.cs | 689 ++++++++++++++++++ .../MCPForUnityEditorWindowNew.cs.meta | 11 + .../Windows/MCPForUnityEditorWindowNew.uss | 279 +++++++ .../MCPForUnityEditorWindowNew.uss.meta | 10 + .../Windows/MCPForUnityEditorWindowNew.uxml | 92 +++ .../MCPForUnityEditorWindowNew.uxml.meta | 10 + 6 files changed, 1091 insertions(+) create mode 100644 MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.cs create mode 100644 MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.cs.meta create mode 100644 MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.uss create mode 100644 MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.uss.meta create mode 100644 MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.uxml create mode 100644 MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.uxml.meta diff --git a/MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.cs b/MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.cs new file mode 100644 index 00000000..f8bd240d --- /dev/null +++ b/MCPForUnity/Editor/Windows/MCPForUnityEditorWindowNew.cs @@ -0,0 +1,689 @@ +using System; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; +using MCPForUnity.Editor.Data; +using MCPForUnity.Editor.Helpers; +using MCPForUnity.Editor.Models; + +namespace MCPForUnity.Editor.Windows +{ + public class MCPForUnityEditorWindowNew : EditorWindow + { + // Protocol enum for future HTTP support + private enum ConnectionProtocol + { + Stdio, + // HTTPStreaming // Future + } + + // UI Elements + private Toggle debugLogsToggle; + private EnumField validationLevelField; + private Label validationDescription; + private EnumField protocolDropdown; + private TextField unityPortField; + private TextField serverPortField; + private VisualElement statusIndicator; + private Label connectionStatusLabel; + private Button connectionToggleButton; + private Button rebuildServerButton; + private DropdownField clientDropdown; + private VisualElement clientStatusIndicator; + private Label clientStatusLabel; + private Button configureButton; + private Foldout manualConfigFoldout; + private TextField configPathField; + private Button copyPathButton; + private Button openFileButton; + private TextField configJsonField; + private Button copyJsonButton; + private Label installationStepsLabel; + + // Data + private readonly McpClients mcpClients = new(); + private int selectedClientIndex = 0; + private ValidationLevel currentValidationLevel = ValidationLevel.Standard; + + // Validation levels matching the existing enum + private enum ValidationLevel + { + Basic, + Standard, + Comprehensive, + Strict + } + + public static void ShowWindow() + { + var window = GetWindow("MCP For Unity"); + window.minSize = new Vector2(500, 600); + } + + public void CreateGUI() + { + // Load UXML + var visualTree = AssetDatabase.LoadAssetAtPath( + "Packages/com.coplaydev.unity-mcp/Editor/Windows/MCPForUnityEditorWindowNew.uxml" + ); + visualTree.CloneTree(rootVisualElement); + + // Load USS + var styleSheet = AssetDatabase.LoadAssetAtPath( + "Packages/com.coplaydev.unity-mcp/Editor/Windows/MCPForUnityEditorWindowNew.uss" + ); + rootVisualElement.styleSheets.Add(styleSheet); + + // Cache UI elements + CacheUIElements(); + + // Initialize UI + InitializeUI(); + + // Register callbacks + RegisterCallbacks(); + + // Initial update + UpdateConnectionStatus(); + UpdateClientStatus(); + } + + private void CacheUIElements() + { + debugLogsToggle = rootVisualElement.Q("debug-logs-toggle"); + validationLevelField = rootVisualElement.Q("validation-level"); + validationDescription = rootVisualElement.Q