diff --git a/MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.uxml b/MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.uxml index 1cfe9c8..36ef452 100644 --- a/MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.uxml +++ b/MCPForUnity/Editor/Windows/Components/ClientConfig/McpClientConfigSection.uxml @@ -7,7 +7,6 @@ - @@ -37,6 +36,7 @@ + diff --git a/MCPForUnity/Editor/Windows/Components/Common.uss b/MCPForUnity/Editor/Windows/Components/Common.uss index 3938555..bf2b3b7 100644 --- a/MCPForUnity/Editor/Windows/Components/Common.uss +++ b/MCPForUnity/Editor/Windows/Components/Common.uss @@ -26,7 +26,9 @@ } /* Remove bottom margin from last section in a stack */ -.section-stack > .section:last-child { +/* Note: Unity UI Toolkit doesn't support :last-child pseudo-class. + The .section-last class is applied programmatically instead. */ +.section-stack > .section.section-last { margin-bottom: 0px; } diff --git a/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs b/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs index d77ea82..b21d70d 100644 --- a/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs +++ b/MCPForUnity/Editor/Windows/MCPForUnityEditorWindow.cs @@ -278,6 +278,10 @@ namespace MCPForUnity.Editor.Windows McpLog.Warn("Failed to load tools section UXML. Tool configuration will be unavailable."); } + // Apply .section-last class to last section in each stack + // (Unity UI Toolkit doesn't support :last-child pseudo-class) + ApplySectionLastClasses(); + guiCreated = true; // Initial updates @@ -300,6 +304,29 @@ namespace MCPForUnity.Editor.Windows toolsSection.Refresh(); } + /// + /// Applies the .section-last class to the last .section element in each .section-stack container. + /// This is a workaround for Unity UI Toolkit not supporting the :last-child pseudo-class. + /// + private void ApplySectionLastClasses() + { + var sectionStacks = rootVisualElement.Query(className: "section-stack").ToList(); + foreach (var stack in sectionStacks) + { + var sections = stack.Children().Where(c => c.ClassListContains("section")).ToList(); + if (sections.Count > 0) + { + // Remove class from all sections first (in case of refresh) + foreach (var section in sections) + { + section.RemoveFromClassList("section-last"); + } + // Add class to the last section + sections[sections.Count - 1].AddToClassList("section-last"); + } + } + } + // Throttle OnEditorUpdate to avoid per-frame overhead (GitHub issue #577). // Connection status polling every frame caused expensive network checks 60+ times/sec. private double _lastEditorUpdateTime;