Skip to content

Minor Fix on Advanced Setting UI#459

Merged
Scriptwonder merged 36 commits into
CoplayDev:mainfrom
Scriptwonder:main
Dec 13, 2025
Merged

Minor Fix on Advanced Setting UI#459
Scriptwonder merged 36 commits into
CoplayDev:mainfrom
Scriptwonder:main

Conversation

@Scriptwonder

@Scriptwonder Scriptwonder commented Dec 13, 2025

Copy link
Copy Markdown
Collaborator

Refine the Server/Source deployment

Summary by CodeRabbit

  • New Features

    • Added Git URL browsing button in settings, enabling users to easily select and configure custom Git URLs.
  • Improvements

    • Deployment source path field is now editable with enhanced validation and error handling.

✏️ Tip: You can customize this high-level summary in your review settings.

* Update the .Bat file to include runtime folder
* Fix the inconsistent EditorPrefs variable so the GUI change on Script Validation could cause real change.
String to Int for consistency
Allows users to generate/compile codes during Playmode
Upload the unity_claude_skill that can be uploaded to Claude for a combo of unity-mcp-skill.
1. Fix Original Roslyn Compilation Custom Tool to fit the V8 standard
2. Add a new panel in the GUI to see and toggle/untoggle the tools. The toggle feature will be implemented in the future, right now its implemented here to discuss with the team if this is a good feature to add;
3. Add few missing summary in certain tools
Merge and use the previous PR's solution to solve the windows issue.
Fix the layout problem of manage_script in the panel
To comply with the current server setting
Tested object generation/modification with batch and it works perfectly! We should push and let users test for a while and see

PS: I tried both VS Copilot and Claude Desktop. Claude Desktop works but VS Copilot does not due to the nested structure of batch. Will look into it more.
This reverts commit 55ee768, reversing
changes made to ae2eedd.
* Enable Camera Capture through both play and editor mode
Notes: Because the standard ScreenCapture.CaptureScreenshot does not work in editor mode, so we use ScreenCapture.CaptureScreenshotIntoRenderTexture to enable it during play mode.

* user can access the camera access through the tool menu, or through direct LLM calling. Both tested on Windows with Claude Desktop.
nitpicking changes
Similar to deploy.bat, but sideload it to MCP For Unity for easier deployment inside Unity menu.
@coderabbitai

coderabbitai Bot commented Dec 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The PR introduces a Git URL browsing button in the MCP Settings UI that opens a folder dialog for selection, persists the chosen path via EditorPrefs, and adds validation logic to the deployment source path field with error handling and service integration.

Changes

Cohort / File(s) Summary
Git URL Browsing Feature
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs, McpSettingsSection.uxml
Added browseGitUrlButton field with click callback that opens a folder dialog, stores the selected path in gitUrlOverride, persists via EditorPrefs, and triggers events. Added corresponding "Select" button in UXML next to the git-url-override field.
Deployment Source Path Handling
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs, McpSettingsSection.uxml
Enhanced deploySourcePath value change handler with validation to skip empty values, call MCPServiceLocator.Deployment.SetStoredSourcePath(), show error dialogs on failure, and refresh UI. Replaced ternary operator with null-coalescing in UpdateDeploymentSection(). Made deploy source path field editable by removing readonly attribute in UXML.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Button wiring and folder dialog logic: Verify the folder dialog opens correctly and selected path is properly captured and persisted
  • Service integration: Ensure MCPServiceLocator.Deployment.SetStoredSourcePath() error handling and event triggering work as intended
  • UI field consistency: Confirm the readonly removal on deploy-source-path aligns with the new validation flow and doesn't introduce unintended side effects

Possibly related PRs

  • PR #450: Implements the PackageDeploymentService and underlying deployment UI/wiring that this PR calls into via MCPServiceLocator.Deployment.SetStoredSourcePath(), making it directly connected to the validation enhancement.

Poem

🐰 A button hops through folders with glee,
Git URLs now browsable, easy to see!
Validation ensures paths are sound,
Settings refined, with robustness found.
Click, store, persist—hopping through thee! 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Minor Fix on Advanced Setting UI' is vague and doesn't clearly convey the specific changes made. While it references the UI component being modified, it lacks specificity about what was actually changed (Git URL browsing, deployment source path handling) and uses non-descriptive language like 'Minor Fix'. Consider a more specific title that highlights the main changes, such as 'Add Git URL browse button and make deploy source path editable' or 'Enhance deployment settings UI with Git URL browsing'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml (1)

38-38: Consider UX clarity for the browse button.

The button labeled "Select" opens a folder panel (per the CS implementation), but the field label "Server Path/URL:" and placeholder text suggest that both local paths and Git URLs (e.g., git+https://...) are valid inputs. Users wanting to specify a Git URL must manually type it rather than browse. This is functional but may cause brief confusion.

Consider either:

  • Renaming the button to "Browse Local..." to clarify it's for local paths only, or
  • Adding a help tooltip to the button indicating it's for local folder selection
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs (1)

276-287: Remove redundant EditorPrefs update and event invocations.

Lines 282-284 duplicate work already performed by the RegisterValueChangedCallback on Lines 131-144. When gitUrlOverride.value is set on Line 281, the callback automatically:

  • Updates EditorPrefs
  • Invokes OnGitUrlChanged
  • Invokes OnHttpServerCommandUpdateRequested

Then Lines 282-284 repeat these operations, causing events to fire twice.

Note: The clearGitUrlButton handler (Lines 146-152) has the same redundancy pattern, so this is consistent with existing code. However, both handlers should be fixed for correctness and efficiency.

Apply this diff to remove redundancy:

 private void OnBrowseGitUrlClicked()
 {
     string picked = EditorUtility.OpenFolderPanel("Select Server folder", string.Empty, string.Empty);
     if (!string.IsNullOrEmpty(picked))
     {
         gitUrlOverride.value = picked;
-        EditorPrefs.SetString(EditorPrefKeys.GitUrlOverride, picked);
-        OnGitUrlChanged?.Invoke();
-        OnHttpServerCommandUpdateRequested?.Invoke();
         McpLog.Info($"Server source override set to: {picked}");
     }
 }

Consider applying the same fix to the clear button handler:

 clearGitUrlButton.clicked += () =>
 {
     gitUrlOverride.value = string.Empty;
-    EditorPrefs.DeleteKey(EditorPrefKeys.GitUrlOverride);
-    OnGitUrlChanged?.Invoke();
-    OnHttpServerCommandUpdateRequested?.Invoke();
 };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6e0ef23 and 8cacd92.

📒 Files selected for processing (2)
  • MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs (5 hunks)
  • MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs (4)
MCPForUnity/Editor/Services/MCPServiceLocator.cs (1)
  • MCPServiceLocator (11-91)
MCPForUnity/Editor/Services/IPackageDeploymentService.cs (2)
  • SetStoredSourcePath (8-8)
  • GetStoredSourcePath (7-7)
MCPForUnity/Editor/Services/PackageDeploymentService.cs (2)
  • SetStoredSourcePath (23-27)
  • GetStoredSourcePath (18-21)
MCPForUnity/Editor/Constants/EditorPrefKeys.cs (1)
  • EditorPrefKeys (7-48)
🔇 Additional comments (4)
MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.uxml (1)

51-51: LGTM!

Removing readonly allows manual path entry, which pairs well with the validation callback added in the CS file (lines 154-171). This gives users flexibility to either browse or type paths directly.

MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs (3)

31-31: LGTM!

Standard UIElements field declaration and caching pattern, consistent with existing button fields in the class.

Also applies to: 80-80


129-129: LGTM!

Standard callback registration pattern consistent with other button handlers in the class.


294-294: LGTM!

Good use of the null-coalescing operator for cleaner, more idiomatic code.

Comment on lines +154 to +171
deploySourcePath.RegisterValueChangedCallback(evt =>
{
string path = evt.newValue?.Trim();
if (string.IsNullOrEmpty(path) || path == "Not set")
{
return;
}

try
{
MCPServiceLocator.Deployment.SetStoredSourcePath(path);
}
catch (Exception ex)
{
EditorUtility.DisplayDialog("Invalid Source", ex.Message, "OK");
UpdateDeploymentSection();
}
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Address inconsistency and fragile string check.

Two concerns with this validation callback:

  1. Fragile string literal check (Line 157): The hard-coded "Not set" string is not set anywhere in the provided code and could break if display text changes. Consider removing this check and relying solely on the string.IsNullOrEmpty(path) check.

  2. Inconsistent UI refresh: On success, UpdateDeploymentSection() is not called, but on error it is (Line 169). In contrast, OnBrowseDeploySourceClicked (Lines 311-331) calls UpdateDeploymentSection() in both success and error cases. While the TextField itself already displays the user's input, other UI elements like deployStatusLabel may need updating to reflect success.

Apply this diff to improve consistency:

 deploySourcePath.RegisterValueChangedCallback(evt =>
 {
     string path = evt.newValue?.Trim();
-    if (string.IsNullOrEmpty(path) || path == "Not set")
+    if (string.IsNullOrEmpty(path))
     {
         return;
     }
     
     try
     {
         MCPServiceLocator.Deployment.SetStoredSourcePath(path);
+        SetDeployStatus($"Source set: {path}");
     }
     catch (Exception ex)
     {
         EditorUtility.DisplayDialog("Invalid Source", ex.Message, "OK");
-        UpdateDeploymentSection();
+        SetDeployStatus("Invalid source path");
     }
+    
+    UpdateDeploymentSection();
 });

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In MCPForUnity/Editor/Windows/Components/Settings/McpSettingsSection.cs around
lines 154 to 171, remove the fragile hard-coded "Not set" check and rely only on
string.IsNullOrEmpty(path) after trimming; then ensure UpdateDeploymentSection()
is called after a successful SetStoredSourcePath(path) as well as in the catch
block so the UI is refreshed consistently on both success and error (retain the
EditorUtility.DisplayDialog on exception and keep exception message handling).

@Scriptwonder Scriptwonder merged commit 8fe73be into CoplayDev:main Dec 13, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant