fix(editor): only treat dev mode when manifest uses file: path for package; remove dev-mode logs under UPM

main
David Sarno 2025-08-08 08:24:50 -07:00
parent 57592017ae
commit 85202d4ccb
1 changed files with 11 additions and 20 deletions

View File

@ -945,32 +945,23 @@ namespace UnityMcpBridge.Editor.Windows
{
try
{
// Check if we're using a file-based package by looking at the manifest
// Only treat as development if manifest explicitly references a local file path for the package
string manifestPath = Path.Combine(Application.dataPath, "..", "Packages", "manifest.json");
if (File.Exists(manifestPath))
{
if (!File.Exists(manifestPath)) return false;
string manifestContent = File.ReadAllText(manifestPath);
// Look for file-based package reference
if (manifestContent.Contains("file:/") && manifestContent.Contains("unity-mcp"))
// Look specifically for our package dependency set to a file: URL
// This avoids auto-enabling dev mode just because a repo exists elsewhere on disk
if (manifestContent.IndexOf("\"com.justinpbarnett.unity-mcp\"", StringComparison.OrdinalIgnoreCase) >= 0)
{
int idx = manifestContent.IndexOf("com.justinpbarnett.unity-mcp", StringComparison.OrdinalIgnoreCase);
// Crude but effective: check for "file:" in the same line/value
if (manifestContent.IndexOf("file:", idx, StringComparison.OrdinalIgnoreCase) >= 0
&& manifestContent.IndexOf("\n", idx, StringComparison.OrdinalIgnoreCase) > manifestContent.IndexOf("file:", idx, StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
// Also check if we're in a development environment by looking for common dev paths
string[] devIndicators = {
Path.Combine(Application.dataPath, "..", "unity-mcp"),
Path.Combine(Application.dataPath, "..", "..", "unity-mcp"),
};
foreach (string indicator in devIndicators)
{
if (Directory.Exists(indicator) && File.Exists(Path.Combine(indicator, "UnityMcpServer", "src", "server.py")))
{
return true;
}
}
return false;
}
catch