From 46db62bfaa4da44c39d1f6b039665d259e2ae97b Mon Sep 17 00:00:00 2001 From: Justin Barnett Date: Tue, 18 Mar 2025 13:36:22 -0400 Subject: [PATCH] fixed path issues --- .gitignore | 1 + Editor/Commands/ObjectCommandHandler.cs | 5 +++-- Editor/MCPEditorWindow.cs | 6 ------ README.md | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index b39db60..c674e30 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ CLAUDE.md # Python-generated files __pycache__/ +__pycache__.meta build/ dist/ wheels/ diff --git a/Editor/Commands/ObjectCommandHandler.cs b/Editor/Commands/ObjectCommandHandler.cs index 2112b03..99fd258 100644 --- a/Editor/Commands/ObjectCommandHandler.cs +++ b/Editor/Commands/ObjectCommandHandler.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Collections.Generic; using UnityEditor; using UnityEngine.SceneManagement; +using UnityEditor.SceneManagement; namespace MCPServer.Editor.Commands { @@ -249,7 +250,7 @@ namespace MCPServer.Editor.Commands public static object FindObjectsByName(JObject @params) { string name = (string)@params["name"] ?? throw new System.Exception("Parameter 'name' is required."); - var objects = GameObject.FindObjectsOfType() + var objects = GameObject.FindObjectsByType(FindObjectsSortMode.None) .Where(o => o.name.Contains(name)) .Select(o => new { @@ -384,7 +385,7 @@ namespace MCPServer.Editor.Commands .ToList() }; } - + /// /// Creates a directional light game object /// diff --git a/Editor/MCPEditorWindow.cs b/Editor/MCPEditorWindow.cs index a2654e8..27b4da7 100644 --- a/Editor/MCPEditorWindow.cs +++ b/Editor/MCPEditorWindow.cs @@ -83,7 +83,6 @@ public class MCPEditorWindow : EditorWindow private bool isUnityBridgeRunning = false; private Vector2 scrollPosition; private string claudeConfigStatus = "Not configured"; - private bool isPythonServerConnected = false; private string pythonServerStatus = "Not Connected"; private Color pythonServerStatusColor = Color.red; private const int unityPort = 6400; // Hardcoded Unity port @@ -137,7 +136,6 @@ public class MCPEditorWindow : EditorWindow if (await Task.WhenAny(readTask, Task.Delay(1000)) == readTask) { // Connection successful and responsive - isPythonServerConnected = true; pythonServerStatus = "Connected"; pythonServerStatusColor = Color.green; UnityEngine.Debug.Log($"Python server connected successfully on port {unityPort}"); @@ -145,7 +143,6 @@ public class MCPEditorWindow : EditorWindow else { // No response received - isPythonServerConnected = false; pythonServerStatus = "No Response"; pythonServerStatusColor = Color.yellow; UnityEngine.Debug.LogWarning($"Python server not responding on port {unityPort}"); @@ -154,7 +151,6 @@ public class MCPEditorWindow : EditorWindow catch (Exception e) { // Connection established but communication failed - isPythonServerConnected = false; pythonServerStatus = "Communication Error"; pythonServerStatusColor = Color.yellow; UnityEngine.Debug.LogWarning($"Error communicating with Python server: {e.Message}"); @@ -163,7 +159,6 @@ public class MCPEditorWindow : EditorWindow else { // Connection failed - isPythonServerConnected = false; pythonServerStatus = "Not Connected"; pythonServerStatusColor = Color.red; UnityEngine.Debug.LogWarning($"Python server is not running or not accessible on port {unityPort}"); @@ -173,7 +168,6 @@ public class MCPEditorWindow : EditorWindow } catch (Exception e) { - isPythonServerConnected = false; pythonServerStatus = "Connection Error"; pythonServerStatusColor = Color.red; UnityEngine.Debug.LogError($"Error checking Python server connection: {e.Message}"); diff --git a/README.md b/README.md index 5e87028..19c6fb0 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Follow these simple steps to get started with the Unity MCP Server: ```bash pip install uv ``` - - Navigate to `Assets/unity-mcp/Python` in your project + - Navigate to `Python` in your project - Install dependencies: ```bash uv venv @@ -139,7 +139,7 @@ Encountering issues? Here are some common fixes: - **Python Server Not Connected** - Verify the Python server is running (`python server.py` in the `Python` directory). - - Check `config.json` (in `Assets/unity-mcp`) for correct port settings (default: `unity_port: 6400`, `mcp_port: 6500`). + - Check `config.json` for correct port settings (default: `unity_port: 6400`, `mcp_port: 6500`). - Ensure `uv` and dependencies are installed correctly. - **Configuration Issues with Claude Desktop or Cursor**