From 1b69c9ca78c487f3bd92c5fd76e0d1f71e220c74 Mon Sep 17 00:00:00 2001 From: ForeseePretty Date: Tue, 25 Oct 2022 17:26:21 +0800 Subject: [PATCH] =?UTF-8?q?[fix]:=E6=94=AF=E6=8C=81hybridclr=E4=B8=8Eil2cp?= =?UTF-8?q?p=5Fplus=E4=BB=93=E5=BA=93=E6=9B=B4=E6=96=B0=20(#11)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: Data~文件读取修正 * [fix]:支持hybridclr与il2cpp_plus仓库更新 --- Editor/Installer/InstallerController.cs | 15 ++++++---- Editor/Installer/InstallerWindow.cs | 25 +++++++++++++++- Editor/Installer/UpdateController.cs | 36 +++++++++++++++++++++++ Editor/Installer/UpdateController.cs.meta | 3 ++ 4 files changed, 73 insertions(+), 6 deletions(-) create mode 100644 Editor/Installer/UpdateController.cs create mode 100644 Editor/Installer/UpdateController.cs.meta diff --git a/Editor/Installer/InstallerController.cs b/Editor/Installer/InstallerController.cs index f85f07a..84d641e 100644 --- a/Editor/Installer/InstallerController.cs +++ b/Editor/Installer/InstallerController.cs @@ -26,6 +26,11 @@ namespace HybridCLR.Editor.Installer public partial class InstallerController { + private const string hybridclr_repo_path = "hybridclr_repo"; + private const string hybridclr_url = "hybridclr"; + private const string il2cpp_plus_repo_path = "il2cpp_plus_repo"; + private const string il2cpp_plus_url = "il2cpp_plus"; + private string m_Il2CppInstallDirectory; public string Il2CppInstallDirectory @@ -246,7 +251,7 @@ namespace HybridCLR.Editor.Installer return InstallErrorCode.Ok; } - + public bool IsUnity2019(string branch) { return branch.Contains("2019."); @@ -295,14 +300,14 @@ namespace HybridCLR.Editor.Installer BashUtil.CopyDir($"{SettingsUtil.HybridCLRDataPathInPackage}/iOSBuild", buildiOSDir, true); // clone hybridclr - string hybridclrRepoDir = $"{workDir}/hybridclr_repo"; + string hybridclrRepoDir = $"{workDir}/{hybridclr_repo_path}"; { BashUtil.RemoveDir(hybridclrRepoDir); var ret = BashUtil.RunCommand(workDir, "git", new string[] { "clone", "--depth=1", - GetRepoUrl("hybridclr"), + GetRepoUrl(hybridclr_url), hybridclrRepoDir, }); //if (ret != 0) @@ -312,7 +317,7 @@ namespace HybridCLR.Editor.Installer } // clone il2cpp_plus - string il2cppPlusRepoDir = $"{workDir}/il2cpp_plus_repo"; + string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}"; { BashUtil.RemoveDir(il2cppPlusRepoDir); var ret = BashUtil.RunCommand(workDir, "git", new string[] @@ -321,7 +326,7 @@ namespace HybridCLR.Editor.Installer "--depth=1", "-b", il2cppBranch, - GetRepoUrl("il2cpp_plus"), + GetRepoUrl(il2cpp_plus_url), il2cppPlusRepoDir, }); //if (ret != 0) diff --git a/Editor/Installer/InstallerWindow.cs b/Editor/Installer/InstallerWindow.cs index 00765df..0bf71cc 100644 --- a/Editor/Installer/InstallerWindow.cs +++ b/Editor/Installer/InstallerWindow.cs @@ -45,7 +45,13 @@ namespace HybridCLR.Editor.Installer GUILayout.Space(10f); EditorGUILayout.BeginVertical("box"); - EditorGUILayout.LabelField($"安装状态:{(m_Controller.HasInstalledHybridCLR() ? "已安装" : "未安装")}", EditorStyles.boldLabel); + bool hasInstall = m_Controller.HasInstalledHybridCLR(); + EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel); + if (hasInstall) + { + GUIInstallButton("检查更新", "检查", UpdateHybridCLR); + } + GUILayout.Space(5f); EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}"); GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select"); @@ -120,5 +126,22 @@ namespace HybridCLR.Editor.Installer { m_Controller.InitHybridCLR(m_Controller.Il2CppBranch, m_Controller.Il2CppInstallDirectory); } + + private void UpdateHybridCLR() + { + bool hasUpdateIl2Cpp = m_Controller.HasUpdateIl2Cpp(m_Controller.Il2CppBranch); + if (hasUpdateIl2Cpp) + { + bool ret = EditorUtility.DisplayDialog("检查更新", "版本不一致", "更新","取消"); + if (ret) + { + InitHybridCLR(); + } + } + else + { + EditorUtility.DisplayDialog("检查更新", "暂无更新", "确定"); + } + } } } diff --git a/Editor/Installer/UpdateController.cs b/Editor/Installer/UpdateController.cs new file mode 100644 index 0000000..9575661 --- /dev/null +++ b/Editor/Installer/UpdateController.cs @@ -0,0 +1,36 @@ +namespace HybridCLR.Editor.Installer +{ + public partial class InstallerController + { + 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\"", }); + var ret2 = BashUtil.RunCommand2(hybridclrRepoDir, "git", + new string[] { "log", "remotes/origin/HEAD", "-n", "1", "--pretty=format:\"%H\"", }); + if (ret1.StdOut != ret2.StdOut) + { + return true; + } + } + + // last hash il2cpp_plus + string il2cppPlusRepoDir = $"{workDir}/{il2cpp_plus_repo_path}"; + { + var ret1 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git", + new string[] { "log", $"{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }); + var ret2 = BashUtil.RunCommand2(il2cppPlusRepoDir, "git", + new string[] { "log", $"remotes/origin/{il2cppBranch}", "-n", "1", "--pretty=format:\"%H\"", }); + if (ret1.StdOut != ret2.StdOut) + { + return true; + } + } + return false; + } + } +} \ No newline at end of file diff --git a/Editor/Installer/UpdateController.cs.meta b/Editor/Installer/UpdateController.cs.meta new file mode 100644 index 0000000..27ba360 --- /dev/null +++ b/Editor/Installer/UpdateController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 91454a4f0a354d11830642b4d4474d7e +timeCreated: 1665546286 \ No newline at end of file