149 lines
4.9 KiB
C#
149 lines
4.9 KiB
C#
#nullable enable
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// MCP for Unity EditorPrefs 설정 확인 및 수정 도구
|
|
/// </summary>
|
|
public static class FixMCPEditorPrefs
|
|
{
|
|
private const string GitUrlOverrideKey = "MCPForUnity.GitUrlOverride";
|
|
|
|
[MenuItem("Tools/MCP/Fix EditorPrefs Issue")]
|
|
public static void FixEditorPrefs()
|
|
{
|
|
Debug.Log("=== MCP EditorPrefs 확인 시작 ===");
|
|
|
|
// 현재 저장된 값 확인
|
|
string currentValue = EditorPrefs.GetString(GitUrlOverrideKey, "");
|
|
|
|
Debug.Log($"현재 GitUrlOverride 값: '{currentValue}'");
|
|
Debug.Log($"값 길이: {currentValue.Length}");
|
|
|
|
if (!string.IsNullOrEmpty(currentValue))
|
|
{
|
|
// 잘못된 문자가 있는지 확인
|
|
char[] invalidChars = System.IO.Path.GetInvalidPathChars();
|
|
bool hasInvalidChars = currentValue.IndexOfAny(invalidChars) >= 0;
|
|
|
|
if (hasInvalidChars)
|
|
{
|
|
Debug.LogWarning($"⚠️ 잘못된 경로 문자가 감지되었습니다!");
|
|
Debug.LogWarning($"문제가 있는 값: '{currentValue}'");
|
|
|
|
// 잘못된 값 제거
|
|
EditorPrefs.DeleteKey(GitUrlOverrideKey);
|
|
Debug.Log("✅ 잘못된 EditorPrefs 값을 제거했습니다.");
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("경로 문자 검증: 정상");
|
|
|
|
// Path.IsPathRooted() 테스트
|
|
try
|
|
{
|
|
bool isRooted = System.IO.Path.IsPathRooted(currentValue);
|
|
Debug.Log($"IsPathRooted 테스트: {isRooted} (정상)");
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
Debug.LogError($"❌ IsPathRooted 호출 실패: {ex.Message}");
|
|
Debug.LogWarning("잘못된 값을 제거합니다...");
|
|
EditorPrefs.DeleteKey(GitUrlOverrideKey);
|
|
Debug.Log("✅ 잘못된 EditorPrefs 값을 제거했습니다.");
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("GitUrlOverride 값이 비어있습니다. (정상)");
|
|
}
|
|
|
|
Debug.Log("=== MCP EditorPrefs 확인 완료 ===");
|
|
Debug.Log("Unity 에디터를 재시작하거나 MCP 윈도우를 다시 열어주세요.");
|
|
}
|
|
|
|
[MenuItem("Tools/MCP/Show All MCP EditorPrefs")]
|
|
public static void ShowAllMCPPrefs()
|
|
{
|
|
Debug.Log("=== 모든 MCP EditorPrefs 값 ===");
|
|
|
|
string[] keys = new[]
|
|
{
|
|
"MCPForUnity.GitUrlOverride",
|
|
"MCPForUnity.UseHttpTransport",
|
|
"MCPForUnity.HttpTransportScope",
|
|
"MCPForUnity.UvxPath",
|
|
"MCPForUnity.ClaudeCliPath",
|
|
"MCPForUnity.HttpUrl",
|
|
"MCPForUnity.HttpRemoteUrl",
|
|
};
|
|
|
|
foreach (string key in keys)
|
|
{
|
|
if (EditorPrefs.HasKey(key))
|
|
{
|
|
string value = EditorPrefs.GetString(key, "");
|
|
Debug.Log($"{key}: '{value}'");
|
|
}
|
|
else
|
|
{
|
|
Debug.Log($"{key}: (설정되지 않음)");
|
|
}
|
|
}
|
|
}
|
|
|
|
[MenuItem("Tools/MCP/Clear All MCP EditorPrefs")]
|
|
public static void ClearAllMCPPrefs()
|
|
{
|
|
bool confirm = EditorUtility.DisplayDialog(
|
|
"MCP EditorPrefs 초기화",
|
|
"모든 MCP for Unity 설정을 초기화하시겠습니까?\n이 작업은 되돌릴 수 없습니다.",
|
|
"초기화",
|
|
"취소"
|
|
);
|
|
|
|
if (!confirm)
|
|
{
|
|
Debug.Log("취소되었습니다.");
|
|
return;
|
|
}
|
|
|
|
Debug.Log("=== MCP EditorPrefs 초기화 시작 ===");
|
|
|
|
string[] keys = new[]
|
|
{
|
|
"MCPForUnity.GitUrlOverride",
|
|
"MCPForUnity.UseHttpTransport",
|
|
"MCPForUnity.HttpTransportScope",
|
|
"MCPForUnity.LastLocalHttpServerPid",
|
|
"MCPForUnity.LastLocalHttpServerPort",
|
|
"MCPForUnity.LastLocalHttpServerStartedUtc",
|
|
"MCPForUnity.LastLocalHttpServerPidArgsHash",
|
|
"MCPForUnity.LastLocalHttpServerPidFilePath",
|
|
"MCPForUnity.LastLocalHttpServerInstanceToken",
|
|
"MCPForUnity.UvxPath",
|
|
"MCPForUnity.ClaudeCliPath",
|
|
"MCPForUnity.HttpUrl",
|
|
"MCPForUnity.HttpRemoteUrl",
|
|
"MCPForUnity.DebugLogs",
|
|
"MCPForUnity.ValidationLevel",
|
|
"MCPForUnity.UnitySocketPort",
|
|
"MCPForUnity.ResumeHttpAfterReload",
|
|
"MCPForUnity.ResumeStdioAfterReload",
|
|
};
|
|
|
|
foreach (string key in keys)
|
|
{
|
|
if (EditorPrefs.HasKey(key))
|
|
{
|
|
EditorPrefs.DeleteKey(key);
|
|
Debug.Log($"✅ 삭제: {key}");
|
|
}
|
|
}
|
|
|
|
Debug.Log("=== MCP EditorPrefs 초기화 완료 ===");
|
|
Debug.Log("Unity 에디터를 재시작해주세요.");
|
|
}
|
|
}
|