Skip to content

Commit 560624c

Browse files
committed
이제
McpSettingsSection 의 중복 코드를 깔끔하게 제거하고, 상단 상태바( Setup Section)에 합병된 구조와 일치시켰습니다.
1 parent a90033d commit 560624c

File tree

2 files changed

+4
-273
lines changed

2 files changed

+4
-273
lines changed

MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs

Lines changed: 4 additions & 228 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ namespace MCPForUnity.Editor.Windows.Components.Settings
1313
{
1414
/// <summary>
1515
/// Controller for the Settings section of the MCP For Unity editor window.
16-
/// Handles version display, debug logs, validation level, and advanced path overrides.
16+
/// Handles version display, debug logs, validation level.
17+
/// Advanced settings and overrides are handled in McpSetupSection or McpClientConfigSection.
1718
/// </summary>
1819
public class McpSettingsSection
1920
{
@@ -22,22 +23,6 @@ public class McpSettingsSection
2223
private Toggle debugLogsToggle;
2324
private EnumField validationLevelField;
2425
private Label validationDescription;
25-
private Foldout advancedSettingsFoldout;
26-
private TextField uvxPathOverride;
27-
private Button browseUvxButton;
28-
private Button clearUvxButton;
29-
private VisualElement uvxPathStatus;
30-
private TextField gitUrlOverride;
31-
private Button browseGitUrlButton;
32-
private Button clearGitUrlButton;
33-
private TextField deploySourcePath;
34-
private Button browseDeploySourceButton;
35-
private Button clearDeploySourceButton;
36-
private Button deployButton;
37-
private Button deployRestoreButton;
38-
private Label deployTargetLabel;
39-
private Label deployBackupLabel;
40-
private Label deployStatusLabel;
4126

4227
// Data
4328
private ValidationLevel currentValidationLevel = ValidationLevel.Standard;
@@ -71,22 +56,6 @@ private void CacheUIElements()
7156
debugLogsToggle = Root.Q<Toggle>("debug-logs-toggle");
7257
validationLevelField = Root.Q<EnumField>("validation-level");
7358
validationDescription = Root.Q<Label>("validation-description");
74-
advancedSettingsFoldout = Root.Q<Foldout>("advanced-settings-foldout");
75-
uvxPathOverride = Root.Q<TextField>("uv-path-override");
76-
browseUvxButton = Root.Q<Button>("browse-uv-button");
77-
clearUvxButton = Root.Q<Button>("clear-uv-button");
78-
uvxPathStatus = Root.Q<VisualElement>("uv-path-status");
79-
gitUrlOverride = Root.Q<TextField>("git-url-override");
80-
browseGitUrlButton = Root.Q<Button>("browse-git-url-button");
81-
clearGitUrlButton = Root.Q<Button>("clear-git-url-button");
82-
deploySourcePath = Root.Q<TextField>("deploy-source-path");
83-
browseDeploySourceButton = Root.Q<Button>("browse-deploy-source-button");
84-
clearDeploySourceButton = Root.Q<Button>("clear-deploy-source-button");
85-
deployButton = Root.Q<Button>("deploy-button");
86-
deployRestoreButton = Root.Q<Button>("deploy-restore-button");
87-
deployTargetLabel = Root.Q<Label>("deploy-target-label");
88-
deployBackupLabel = Root.Q<Label>("deploy-backup-label");
89-
deployStatusLabel = Root.Q<Label>("deploy-status-label");
9059
}
9160

9261
private void InitializeUI()
@@ -117,66 +86,12 @@ private void RegisterCallbacks()
11786
EditorPrefs.SetInt(EditorPrefKeys.ValidationLevel, (int)currentValidationLevel);
11887
UpdateValidationDescription();
11988
});
120-
121-
browseUvxButton.clicked += OnBrowseUvxClicked;
122-
clearUvxButton.clicked += OnClearUvxClicked;
123-
124-
browseGitUrlButton.clicked += OnBrowseGitUrlClicked;
125-
126-
gitUrlOverride.RegisterValueChangedCallback(evt =>
127-
{
128-
string url = evt.newValue?.Trim();
129-
if (string.IsNullOrEmpty(url))
130-
{
131-
EditorPrefs.DeleteKey(EditorPrefKeys.GitUrlOverride);
132-
}
133-
else
134-
{
135-
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, url);
136-
}
137-
OnGitUrlChanged?.Invoke();
138-
OnHttpServerCommandUpdateRequested?.Invoke();
139-
});
140-
141-
clearGitUrlButton.clicked += () =>
142-
{
143-
gitUrlOverride.value = string.Empty;
144-
EditorPrefs.DeleteKey(EditorPrefKeys.GitUrlOverride);
145-
OnGitUrlChanged?.Invoke();
146-
OnHttpServerCommandUpdateRequested?.Invoke();
147-
};
148-
149-
deploySourcePath.RegisterValueChangedCallback(evt =>
150-
{
151-
string path = evt.newValue?.Trim();
152-
if (string.IsNullOrEmpty(path) || path == "Not set")
153-
{
154-
return;
155-
}
156-
157-
try
158-
{
159-
MCPServiceLocator.Deployment.SetStoredSourcePath(path);
160-
}
161-
catch (Exception ex)
162-
{
163-
EditorUtility.DisplayDialog("Invalid Source", ex.Message, "OK");
164-
UpdateDeploymentSection();
165-
}
166-
});
167-
168-
browseDeploySourceButton.clicked += OnBrowseDeploySourceClicked;
169-
clearDeploySourceButton.clicked += OnClearDeploySourceClicked;
170-
deployButton.clicked += OnDeployClicked;
171-
deployRestoreButton.clicked += OnRestoreBackupClicked;
17289
}
17390

17491
public void UpdatePathOverrides()
17592
{
176-
// Now handled in Setup Section, but kept empty method if called externally to prevent crashes momentarily,
177-
// or we can remove it if we are sure no one calls it.
178-
// Based on previous search, it seemed to be called by EditorWindow.RefreshAllData.
179-
// Let's keep it empty for safety or remove the call in EditorWindow.
93+
// Now handled in Setup Section or Client Config
94+
// Kept empty method for compatibility with existing calls
18095
}
18196

18297
private void UpdateVersionLabel()
@@ -215,144 +130,5 @@ private string GetValidationLevelDescription(int index)
215130
_ => "Standard validation"
216131
};
217132
}
218-
219-
private void OnBrowseUvxClicked()
220-
{
221-
string suggested = RuntimeInformation.IsOSPlatform(OSPlatform.OSX)
222-
? "/opt/homebrew/bin"
223-
: Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
224-
string picked = EditorUtility.OpenFilePanel("Select uv Executable", suggested, "");
225-
if (!string.IsNullOrEmpty(picked))
226-
{
227-
try
228-
{
229-
MCPServiceLocator.Paths.SetUvxPathOverride(picked);
230-
UpdatePathOverrides();
231-
McpLog.Info($"uv path override set to: {picked}");
232-
}
233-
catch (Exception ex)
234-
{
235-
EditorUtility.DisplayDialog("Invalid Path", ex.Message, "OK");
236-
}
237-
}
238-
}
239-
240-
private void OnClearUvxClicked()
241-
{
242-
MCPServiceLocator.Paths.ClearUvxPathOverride();
243-
UpdatePathOverrides();
244-
McpLog.Info("uv path override cleared");
245-
}
246-
247-
private void OnBrowseGitUrlClicked()
248-
{
249-
string picked = EditorUtility.OpenFolderPanel("Select Server folder", string.Empty, string.Empty);
250-
if (!string.IsNullOrEmpty(picked))
251-
{
252-
gitUrlOverride.value = picked;
253-
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, picked);
254-
OnGitUrlChanged?.Invoke();
255-
OnHttpServerCommandUpdateRequested?.Invoke();
256-
McpLog.Info($"Server source override set to: {picked}");
257-
}
258-
}
259-
260-
private void UpdateDeploymentSection()
261-
{
262-
var deployService = MCPServiceLocator.Deployment;
263-
264-
string sourcePath = deployService.GetStoredSourcePath();
265-
deploySourcePath.value = sourcePath ?? string.Empty;
266-
267-
deployTargetLabel.text = $"Target: {deployService.GetTargetDisplayPath()}";
268-
269-
string backupPath = deployService.GetLastBackupPath();
270-
if (deployService.HasBackup())
271-
{
272-
deployBackupLabel.text = $"Last backup: {backupPath}";
273-
}
274-
else
275-
{
276-
deployBackupLabel.text = "Last backup: none";
277-
}
278-
279-
deployRestoreButton?.SetEnabled(deployService.HasBackup());
280-
}
281-
282-
private void OnBrowseDeploySourceClicked()
283-
{
284-
string picked = EditorUtility.OpenFolderPanel("Select MCPForUnity folder", string.Empty, string.Empty);
285-
if (string.IsNullOrEmpty(picked))
286-
{
287-
return;
288-
}
289-
290-
try
291-
{
292-
MCPServiceLocator.Deployment.SetStoredSourcePath(picked);
293-
SetDeployStatus($"Source set: {picked}");
294-
}
295-
catch (Exception ex)
296-
{
297-
EditorUtility.DisplayDialog("Invalid Source", ex.Message, "OK");
298-
SetDeployStatus("Source selection failed");
299-
}
300-
301-
UpdateDeploymentSection();
302-
}
303-
304-
private void OnClearDeploySourceClicked()
305-
{
306-
MCPServiceLocator.Deployment.ClearStoredSourcePath();
307-
UpdateDeploymentSection();
308-
SetDeployStatus("Source cleared");
309-
}
310-
311-
private void OnDeployClicked()
312-
{
313-
var result = MCPServiceLocator.Deployment.DeployFromStoredSource();
314-
SetDeployStatus(result.Message, !result.Success);
315-
316-
if (!result.Success)
317-
{
318-
EditorUtility.DisplayDialog("Deployment Failed", result.Message, "OK");
319-
}
320-
else
321-
{
322-
EditorUtility.DisplayDialog("Deployment Complete", result.Message + (string.IsNullOrEmpty(result.BackupPath) ? string.Empty : $"\nBackup: {result.BackupPath}"), "OK");
323-
}
324-
325-
UpdateDeploymentSection();
326-
}
327-
328-
private void OnRestoreBackupClicked()
329-
{
330-
var result = MCPServiceLocator.Deployment.RestoreLastBackup();
331-
SetDeployStatus(result.Message, !result.Success);
332-
333-
if (!result.Success)
334-
{
335-
EditorUtility.DisplayDialog("Restore Failed", result.Message, "OK");
336-
}
337-
else
338-
{
339-
EditorUtility.DisplayDialog("Restore Complete", result.Message, "OK");
340-
}
341-
342-
UpdateDeploymentSection();
343-
}
344-
345-
private void SetDeployStatus(string message, bool isError = false)
346-
{
347-
if (deployStatusLabel == null)
348-
{
349-
return;
350-
}
351-
352-
deployStatusLabel.text = message;
353-
deployStatusLabel.style.color = isError
354-
? new StyleColor(new Color(0.85f, 0.2f, 0.2f))
355-
: StyleKeyword.Null;
356-
}
357133
}
358134
}

MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,6 @@
1616
<uie:EnumField name="validation-level" class="setting-dropdown" />
1717
<ui:Label name="validation-description" class="validation-description" />
1818
</ui:VisualElement>
19-
<ui:Foldout name="advanced-settings-foldout" text="Advanced Settings" class="advanced-settings-foldout">
20-
<ui:VisualElement class="advanced-settings-content">
21-
<ui:Label text="Path Overrides (leave empty for auto-detection):" class="advanced-label" />
22-
<ui:VisualElement class="override-row">
23-
<ui:Label text="UV Path:" class="override-label" />
24-
<ui:VisualElement class="status-indicator-small" name="uv-path-status" />
25-
</ui:VisualElement>
26-
<ui:VisualElement class="path-override-controls">
27-
<ui:TextField name="uv-path-override" readonly="true" class="override-field" />
28-
<ui:Button name="browse-uv-button" text="Browse" class="icon-button" />
29-
<ui:Button name="clear-uv-button" text="Clear" class="icon-button" />
30-
</ui:VisualElement>
31-
<ui:Label text="Server Source Override:" class="advanced-label" style="margin-top: 10px;" />
32-
<ui:Label text="Override the source used for uvx --from. Leave empty to use default package." class="help-text" />
33-
<ui:VisualElement class="override-row">
34-
<ui:Label text="Server Path/URL:" class="override-label" />
35-
</ui:VisualElement>
36-
<ui:VisualElement class="path-override-controls">
37-
<ui:TextField name="git-url-override" placeholder-text="/path/to/Server or git+https://..." class="override-field" />
38-
<ui:Button name="browse-git-url-button" text="Select" class="icon-button" />
39-
<ui:Button name="clear-git-url-button" text="Clear" class="icon-button" />
40-
</ui:VisualElement>
41-
<ui:Label text="Examples:" class="help-text" style="margin-top: 5px;" />
42-
<ui:Label text="• Local: /Users/you/Projects/unity-mcp/Server" class="help-text" />
43-
<ui:Label text="• Remote: git+https://github.com/CoplayDev/unity-mcp@v6.3.0#subdirectory=Server" class="help-text" />
44-
45-
<ui:Label text="Local Package Deployment:" class="advanced-label" style="margin-top: 12px;" />
46-
<ui:Label text="Copy a MCPForUnity folder into this project's package location." class="help-text" />
47-
<ui:VisualElement class="override-row">
48-
<ui:Label text="MCP For Unity Source Folder:" class="override-label" />
49-
</ui:VisualElement>
50-
<ui:VisualElement class="path-override-controls">
51-
<ui:TextField name="deploy-source-path" class="override-field" />
52-
<ui:Button name="browse-deploy-source-button" text="Select" class="icon-button" />
53-
<ui:Button name="clear-deploy-source-button" text="Clear" class="icon-button" />
54-
</ui:VisualElement>
55-
<ui:Label name="deploy-target-label" class="help-text" />
56-
<ui:Label name="deploy-backup-label" class="help-text" />
57-
<ui:VisualElement class="path-override-controls" style="margin-top: 4px;">
58-
<ui:Button name="deploy-button" text="Deploy to Project" class="icon-button" />
59-
<ui:Button name="deploy-restore-button" text="Restore Last Backup" class="icon-button" />
60-
</ui:VisualElement>
61-
<ui:Label name="deploy-status-label" class="help-text" />
62-
</ui:VisualElement>
63-
</ui:Foldout>
6419
</ui:VisualElement>
6520
</ui:VisualElement>
6621
</ui:UXML>

0 commit comments

Comments
 (0)