UnityMcpPackageSetup.cs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. using UnityEditor;
  2. using UnityEngine;
  3. public static class UnityMcpPackageSetup
  4. {
  5. public const string PackageName = "com.coplaydev.unity-mcp";
  6. public const string PackageUrl = "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main";
  7. static readonly EditorPackageInstaller Installer = new EditorPackageInstaller(
  8. PackageName, PackageUrl, "Unity MCP", "AppRuntimes.UnityMcp", "Use AppSettings/Install Unity MCP.");
  9. public static bool IsInstalled => Installer.IsInstalled;
  10. public static bool IsInstalling => Installer.IsInstalling;
  11. public static string LastError => Installer.LastError;
  12. [MenuItem("AppSettings/Install Unity MCP", false, 101)]
  13. public static void Install()
  14. {
  15. if (IsInstalled)
  16. {
  17. Debug.Log("[AppRuntimes] Unity MCP is already installed.");
  18. return;
  19. }
  20. Installer.Retry();
  21. }
  22. [MenuItem("AppSettings/Install Unity MCP", true, 101)]
  23. static bool CanInstall() => !IsInstalling && !EditorApplication.isCompiling && !EditorApplication.isUpdating
  24. && !EditorApplication.isPlayingOrWillChangePlaymode && !BuildPipeline.isBuildingPlayer;
  25. }