Skip to content

Commit 8fe73be

Browse files
authored
Minor Fix on Advanced Setting UI (#459)
* [FIX] Input refinment on Advanced Settings Add a browse for server and make the source input more than readonly
1 parent 6e0ef23 commit 8fe73be

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class McpSettingsSection
2828
private Button clearUvxButton;
2929
private VisualElement uvxPathStatus;
3030
private TextField gitUrlOverride;
31+
private Button browseGitUrlButton;
3132
private Button clearGitUrlButton;
3233
private TextField deploySourcePath;
3334
private Button browseDeploySourceButton;
@@ -76,6 +77,7 @@ private void CacheUIElements()
7677
clearUvxButton = Root.Q<Button>("clear-uv-button");
7778
uvxPathStatus = Root.Q<VisualElement>("uv-path-status");
7879
gitUrlOverride = Root.Q<TextField>("git-url-override");
80+
browseGitUrlButton = Root.Q<Button>("browse-git-url-button");
7981
clearGitUrlButton = Root.Q<Button>("clear-git-url-button");
8082
deploySourcePath = Root.Q<TextField>("deploy-source-path");
8183
browseDeploySourceButton = Root.Q<Button>("browse-deploy-source-button");
@@ -124,6 +126,8 @@ private void RegisterCallbacks()
124126
browseUvxButton.clicked += OnBrowseUvxClicked;
125127
clearUvxButton.clicked += OnClearUvxClicked;
126128

129+
browseGitUrlButton.clicked += OnBrowseGitUrlClicked;
130+
127131
gitUrlOverride.RegisterValueChangedCallback(evt =>
128132
{
129133
string url = evt.newValue?.Trim();
@@ -147,6 +151,25 @@ private void RegisterCallbacks()
147151
OnHttpServerCommandUpdateRequested?.Invoke();
148152
};
149153

154+
deploySourcePath.RegisterValueChangedCallback(evt =>
155+
{
156+
string path = evt.newValue?.Trim();
157+
if (string.IsNullOrEmpty(path) || path == "Not set")
158+
{
159+
return;
160+
}
161+
162+
try
163+
{
164+
MCPServiceLocator.Deployment.SetStoredSourcePath(path);
165+
}
166+
catch (Exception ex)
167+
{
168+
EditorUtility.DisplayDialog("Invalid Source", ex.Message, "OK");
169+
UpdateDeploymentSection();
170+
}
171+
});
172+
150173
browseDeploySourceButton.clicked += OnBrowseDeploySourceClicked;
151174
clearDeploySourceButton.clicked += OnClearDeploySourceClicked;
152175
deployButton.clicked += OnDeployClicked;
@@ -250,12 +273,25 @@ private void OnClearUvxClicked()
250273
McpLog.Info("uv path override cleared");
251274
}
252275

276+
private void OnBrowseGitUrlClicked()
277+
{
278+
string picked = EditorUtility.OpenFolderPanel("Select Server folder", string.Empty, string.Empty);
279+
if (!string.IsNullOrEmpty(picked))
280+
{
281+
gitUrlOverride.value = picked;
282+
EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, picked);
283+
OnGitUrlChanged?.Invoke();
284+
OnHttpServerCommandUpdateRequested?.Invoke();
285+
McpLog.Info($"Server source override set to: {picked}");
286+
}
287+
}
288+
253289
private void UpdateDeploymentSection()
254290
{
255291
var deployService = MCPServiceLocator.Deployment;
256292

257293
string sourcePath = deployService.GetStoredSourcePath();
258-
deploySourcePath.value = string.IsNullOrEmpty(sourcePath) ? "Not set" : sourcePath;
294+
deploySourcePath.value = sourcePath ?? string.Empty;
259295

260296
deployTargetLabel.text = $"Target: {deployService.GetTargetDisplayPath()}";
261297

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
</ui:VisualElement>
3636
<ui:VisualElement class="path-override-controls">
3737
<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" />
3839
<ui:Button name="clear-git-url-button" text="Clear" class="icon-button" />
3940
</ui:VisualElement>
4041
<ui:Label text="Examples:" class="help-text" style="margin-top: 5px;" />
@@ -47,7 +48,7 @@
4748
<ui:Label text="MCP For Unity Source Folder:" class="override-label" />
4849
</ui:VisualElement>
4950
<ui:VisualElement class="path-override-controls">
50-
<ui:TextField name="deploy-source-path" readonly="true" class="override-field" />
51+
<ui:TextField name="deploy-source-path" class="override-field" />
5152
<ui:Button name="browse-deploy-source-button" text="Select" class="icon-button" />
5253
<ui:Button name="clear-deploy-source-button" text="Clear" class="icon-button" />
5354
</ui:VisualElement>

0 commit comments

Comments
 (0)