fixed path issues

main
Justin Barnett 2025-03-18 13:36:22 -04:00
parent 4d1c351364
commit 46db62bfaa
4 changed files with 6 additions and 10 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ CLAUDE.md
# Python-generated files # Python-generated files
__pycache__/ __pycache__/
__pycache__.meta
build/ build/
dist/ dist/
wheels/ wheels/

View File

@ -6,6 +6,7 @@ using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor; using UnityEditor;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
using UnityEditor.SceneManagement;
namespace MCPServer.Editor.Commands namespace MCPServer.Editor.Commands
{ {
@ -249,7 +250,7 @@ namespace MCPServer.Editor.Commands
public static object FindObjectsByName(JObject @params) public static object FindObjectsByName(JObject @params)
{ {
string name = (string)@params["name"] ?? throw new System.Exception("Parameter 'name' is required."); string name = (string)@params["name"] ?? throw new System.Exception("Parameter 'name' is required.");
var objects = GameObject.FindObjectsOfType<GameObject>() var objects = GameObject.FindObjectsByType<GameObject>(FindObjectsSortMode.None)
.Where(o => o.name.Contains(name)) .Where(o => o.name.Contains(name))
.Select(o => new .Select(o => new
{ {

View File

@ -83,7 +83,6 @@ public class MCPEditorWindow : EditorWindow
private bool isUnityBridgeRunning = false; private bool isUnityBridgeRunning = false;
private Vector2 scrollPosition; private Vector2 scrollPosition;
private string claudeConfigStatus = "Not configured"; private string claudeConfigStatus = "Not configured";
private bool isPythonServerConnected = false;
private string pythonServerStatus = "Not Connected"; private string pythonServerStatus = "Not Connected";
private Color pythonServerStatusColor = Color.red; private Color pythonServerStatusColor = Color.red;
private const int unityPort = 6400; // Hardcoded Unity port 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) if (await Task.WhenAny(readTask, Task.Delay(1000)) == readTask)
{ {
// Connection successful and responsive // Connection successful and responsive
isPythonServerConnected = true;
pythonServerStatus = "Connected"; pythonServerStatus = "Connected";
pythonServerStatusColor = Color.green; pythonServerStatusColor = Color.green;
UnityEngine.Debug.Log($"Python server connected successfully on port {unityPort}"); UnityEngine.Debug.Log($"Python server connected successfully on port {unityPort}");
@ -145,7 +143,6 @@ public class MCPEditorWindow : EditorWindow
else else
{ {
// No response received // No response received
isPythonServerConnected = false;
pythonServerStatus = "No Response"; pythonServerStatus = "No Response";
pythonServerStatusColor = Color.yellow; pythonServerStatusColor = Color.yellow;
UnityEngine.Debug.LogWarning($"Python server not responding on port {unityPort}"); UnityEngine.Debug.LogWarning($"Python server not responding on port {unityPort}");
@ -154,7 +151,6 @@ public class MCPEditorWindow : EditorWindow
catch (Exception e) catch (Exception e)
{ {
// Connection established but communication failed // Connection established but communication failed
isPythonServerConnected = false;
pythonServerStatus = "Communication Error"; pythonServerStatus = "Communication Error";
pythonServerStatusColor = Color.yellow; pythonServerStatusColor = Color.yellow;
UnityEngine.Debug.LogWarning($"Error communicating with Python server: {e.Message}"); UnityEngine.Debug.LogWarning($"Error communicating with Python server: {e.Message}");
@ -163,7 +159,6 @@ public class MCPEditorWindow : EditorWindow
else else
{ {
// Connection failed // Connection failed
isPythonServerConnected = false;
pythonServerStatus = "Not Connected"; pythonServerStatus = "Not Connected";
pythonServerStatusColor = Color.red; pythonServerStatusColor = Color.red;
UnityEngine.Debug.LogWarning($"Python server is not running or not accessible on port {unityPort}"); 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) catch (Exception e)
{ {
isPythonServerConnected = false;
pythonServerStatus = "Connection Error"; pythonServerStatus = "Connection Error";
pythonServerStatusColor = Color.red; pythonServerStatusColor = Color.red;
UnityEngine.Debug.LogError($"Error checking Python server connection: {e.Message}"); UnityEngine.Debug.LogError($"Error checking Python server connection: {e.Message}");

View File

@ -33,7 +33,7 @@ Follow these simple steps to get started with the Unity MCP Server:
```bash ```bash
pip install uv pip install uv
``` ```
- Navigate to `Assets/unity-mcp/Python` in your project - Navigate to `Python` in your project
- Install dependencies: - Install dependencies:
```bash ```bash
uv venv uv venv
@ -139,7 +139,7 @@ Encountering issues? Here are some common fixes:
- **Python Server Not Connected** - **Python Server Not Connected**
- Verify the Python server is running (`python server.py` in the `Python` directory). - 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. - Ensure `uv` and dependencies are installed correctly.
- **Configuration Issues with Claude Desktop or Cursor** - **Configuration Issues with Claude Desktop or Cursor**