diff --git a/Editor/Installer/BashUtil.cs b/Editor/Installer/BashUtil.cs index 05770de..08cef29 100644 --- a/Editor/Installer/BashUtil.cs +++ b/Editor/Installer/BashUtil.cs @@ -10,7 +10,7 @@ namespace HybridCLR.Editor.Installer { public static class BashUtil { - public static int RunCommand(string workingDir, string program, string[] args) + public static int RunCommand(string workingDir, string program, string[] args, bool log = true) { using (Process p = new Process()) { @@ -20,7 +20,10 @@ namespace HybridCLR.Editor.Installer p.StartInfo.CreateNoWindow = true; string argsStr = string.Join(" ", args.Select(arg => "\"" + arg + "\"")); p.StartInfo.Arguments = argsStr; - UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}"); + if (log) + { + UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}"); + } p.Start(); p.WaitForExit(); return p.ExitCode; @@ -28,7 +31,7 @@ namespace HybridCLR.Editor.Installer } - public static (int ExitCode, string StdOut, string StdErr) RunCommand2(string workingDir, string program, string[] args) + public static (int ExitCode, string StdOut, string StdErr) RunCommand2(string workingDir, string program, string[] args, bool log = true) { using (Process p = new Process()) { @@ -40,7 +43,10 @@ namespace HybridCLR.Editor.Installer p.StartInfo.RedirectStandardError = true; string argsStr = string.Join(" ", args.Select(arg => "\"" + arg + "\"")); p.StartInfo.Arguments = argsStr; - UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}"); + if (log) + { + UnityEngine.Debug.Log($"[BashUtil] run => {program} {argsStr}"); + } p.Start(); p.WaitForExit(); diff --git a/Editor/Installer/InstallerController.cs b/Editor/Installer/InstallerController.cs index 84c895e..4a3b139 100644 --- a/Editor/Installer/InstallerController.cs +++ b/Editor/Installer/InstallerController.cs @@ -274,8 +274,8 @@ namespace HybridCLR.Editor.Installer private static string GetRepoUrl(string repoName) { - string repoProvider = SettingsUtil.HybridCLRSettings.cloneFromGitee ? "gitee" : "github"; - return $"https://{repoProvider}.com/focus-creative-games/{repoName}"; + string repoProvider = SettingsUtil.HybridCLRSettings.cloneHomeURL; + return $"{repoProvider}/{repoName}"; } private void RunInitLocalIl2CppData(string il2cppBranch, string il2cppInstallPath) diff --git a/Editor/Installer/InstallerWindow.cs b/Editor/Installer/InstallerWindow.cs index 0bf71cc..abff7fd 100644 --- a/Editor/Installer/InstallerWindow.cs +++ b/Editor/Installer/InstallerWindow.cs @@ -44,16 +44,22 @@ namespace HybridCLR.Editor.Installer GUILayout.Space(10f); + EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}"); + GUILayout.Space(5f); + EditorGUILayout.BeginVertical("box"); bool hasInstall = m_Controller.HasInstalledHybridCLR(); EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel); if (hasInstall) { + EditorGUILayout.LabelField($"HybridCLR 版本: {m_Controller.GetHybridCLRLocalVersion()}"); + GUILayout.Space(5f); + EditorGUILayout.LabelField($"il2cpp_plus 版本: {m_Controller.GetIl2cppPlusLocalVersion(m_Controller.Il2CppBranch)}"); + GUILayout.Space(5f); GUIInstallButton("检查更新", "检查", UpdateHybridCLR); + GUILayout.Space(40f); } - GUILayout.Space(5f); - EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}"); GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select"); GUILayout.Space(10f); GUIInstallButton("安装最新HybridCLR插件代码到本项目", "安装", InitHybridCLR); diff --git a/Editor/Installer/UpdateController.cs b/Editor/Installer/UpdateController.cs index c1e133c..445a0ca 100644 --- a/Editor/Installer/UpdateController.cs +++ b/Editor/Installer/UpdateController.cs @@ -1,19 +1,62 @@ -namespace HybridCLR.Editor.Installer +using System.IO; + +namespace HybridCLR.Editor.Installer { public partial class InstallerController { + public string GetHybridCLRLocalVersion() + { + string workDir = SettingsUtil.HybridCLRDataDir; + string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}"; + if (Directory.Exists(hybridclrRepoDir)) + { + var ret = BashUtil.RunCommand2(hybridclrRepoDir, "git", + new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", }, + false); + if (ret.ExitCode == 0) + { + return ret.StdOut.Trim(); + } + else + { + return "ERROR"; + } + } + return ""; + } + + public string GetIl2cppPlusLocalVersion(string il2cppBranch) + { + string workDir = SettingsUtil.HybridCLRDataDir; + string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}"; + if (Directory.Exists(il2cppPlusRepoDir)) + { + var ret = BashUtil.RunCommand2(il2cppPlusRepoDir, "git", + new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, + false); + if (ret.ExitCode == 0) + { + return ret.StdOut.Trim(); + } + else + { + return "ERROR"; + } + } + return ""; + } + public bool HasUpdateIl2Cpp(string il2cppBranch) { string workDir = SettingsUtil.HybridCLRDataDir; // last hash hybridclr { string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}"; - var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git", - new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", }); - BashUtil.RunCommand2(hybridclrRepoDir, "git", - new string[] { "fetch", "--depth=1" }); + var ret1 = BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "log", "HEAD", "-n", "1", "--pretty=format:\"%H\"", }, false); + BashUtil.RunCommand2(hybridclrRepoDir, "git", new string[] { "fetch", "--depth=1" }, false); var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git", - new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", }); + new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", } + , false); if (ret1.StdOut != ret2.StdOut) { return true; @@ -23,11 +66,11 @@ { string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}"; var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git", - new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }); + new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false); BashUtil.RunCommand2(il2cppPlusRepoDir, "git", - new string[] { "fetch", "--depth=1" }); + new string[] { "fetch", "--depth=1" }, false); var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git", - new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }); + new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }, false); if (ret1.StdOut != ret2.StdOut) { return true; diff --git a/Editor/Settings/HybridCLRSettingProvider.cs b/Editor/Settings/HybridCLRSettingProvider.cs index 9207783..bed471f 100644 --- a/Editor/Settings/HybridCLRSettingProvider.cs +++ b/Editor/Settings/HybridCLRSettingProvider.cs @@ -11,7 +11,7 @@ namespace HybridCLR.Editor private SerializedObject _serializedObject; private SerializedProperty _enable; private SerializedProperty _useGlobalIl2cpp; - private SerializedProperty _cloneFromGitee; + private SerializedProperty _cloneHomeURL; private SerializedProperty _hotUpdateAssemblyDefinitions; private SerializedProperty _hotUpdateAssemblies; private SerializedProperty _preserveHotUpdateAssemblies; @@ -39,7 +39,7 @@ namespace HybridCLR.Editor _serializedObject = new SerializedObject(setting); _enable = _serializedObject.FindProperty("enable"); _useGlobalIl2cpp = _serializedObject.FindProperty("useGlobalIl2cpp"); - _cloneFromGitee = _serializedObject.FindProperty("cloneFromGitee"); + _cloneHomeURL = _serializedObject.FindProperty("cloneHomeURL"); _hotUpdateAssemblyDefinitions = _serializedObject.FindProperty("hotUpdateAssemblyDefinitions"); _hotUpdateAssemblies = _serializedObject.FindProperty("hotUpdateAssemblies"); _preserveHotUpdateAssemblies = _serializedObject.FindProperty("preserveHotUpdateAssemblies"); @@ -127,7 +127,7 @@ namespace HybridCLR.Editor _serializedObject.Update(); EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_enable); - EditorGUILayout.PropertyField(_cloneFromGitee); + EditorGUILayout.PropertyField(_cloneHomeURL); EditorGUILayout.PropertyField(_useGlobalIl2cpp); EditorGUILayout.PropertyField(_hotUpdateAssemblyDefinitions); EditorGUILayout.PropertyField(_hotUpdateAssemblies); diff --git a/Editor/Settings/HybridCLRSettings.cs b/Editor/Settings/HybridCLRSettings.cs index 053fc53..49fcddd 100644 --- a/Editor/Settings/HybridCLRSettings.cs +++ b/Editor/Settings/HybridCLRSettings.cs @@ -11,8 +11,8 @@ namespace HybridCLR.Editor [Header("使用全局安装的il2cpp")] public bool useGlobalIl2cpp; - [Header("从gitee clone插件代码")] - public bool cloneFromGitee = true; // false 则从github上拉取 + [Header("基准 git clone URL")] + public string cloneHomeURL = "https://gitee.com/focus-creative-games"; [Header("热更新Assembly Definitions")] public AssemblyDefinitionAsset[] hotUpdateAssemblyDefinitions; diff --git a/package.json b/package.json index 0fde3fd..31fc926 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "0.10.3", + "version": "0.10.4", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",