From 05a34d4d12e65a56d4a908bd1d4aeafb4300194b Mon Sep 17 00:00:00 2001 From: walon Date: Sun, 15 Oct 2023 12:44:22 +0800 Subject: [PATCH] =?UTF-8?q?[new]=20=E6=A3=80=E6=9F=A5=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E7=9A=84libil2cpp=E7=89=88=E6=9C=AC=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=8Epackage=E7=89=88=E6=9C=AC=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=EF=BC=8C=E9=81=BF=E5=85=8D=E5=8D=87=E7=BA=A7package=E5=90=8E?= =?UTF-8?q?=E6=9C=AA=E9=87=8D=E6=96=B0install=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/BuildProcessors/CheckSettings.cs | 5 +++++ Editor/Installer/InstallerController.cs | 21 +++++++++++++++++++++ Editor/Installer/InstallerWindow.cs | 4 +++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Editor/BuildProcessors/CheckSettings.cs b/Editor/BuildProcessors/CheckSettings.cs index dd397aa..a5840bc 100644 --- a/Editor/BuildProcessors/CheckSettings.cs +++ b/Editor/BuildProcessors/CheckSettings.cs @@ -56,6 +56,11 @@ namespace HybridCLR.Editor.BuildProcessors throw new BuildFailedException($"You have not initialized HybridCLR, please install it via menu 'HybridCLR/Installer'"); } + if (installer.PackageVersion != installer.InstalledLibil2cppVersion) + { + throw new BuildFailedException($"You must run `HybridCLR/Installer` after upgrading package"); + } + HybridCLRSettings gs = SettingsUtil.HybridCLRSettings; if (((gs.hotUpdateAssemblies?.Length + gs.hotUpdateAssemblyDefinitions?.Length) ?? 0) == 0) { diff --git a/Editor/Installer/InstallerController.cs b/Editor/Installer/InstallerController.cs index 768515f..c44186f 100644 --- a/Editor/Installer/InstallerController.cs +++ b/Editor/Installer/InstallerController.cs @@ -27,12 +27,15 @@ namespace HybridCLR.Editor.Installer public string PackageVersion { get; private set; } + public string InstalledLibil2cppVersion { get; private set; } + public InstallerController() { _curVersion = ParseUnityVersion(Application.unityVersion); _versionManifest = GetHybridCLRVersionManifest(); _curDefaultVersion = _versionManifest.versions.FirstOrDefault(v => v.unity_version == _curVersion.major.ToString()); PackageVersion = LoadPackageInfo().version; + InstalledLibil2cppVersion = ReadLocalVersion(); } private HybridclrVersionManifest GetHybridCLRVersionManifest() @@ -157,6 +160,23 @@ namespace HybridCLR.Editor.Installer public string ApplicationIl2cppPath => GetIl2CppPathByContentPath(EditorApplication.applicationContentsPath); + public string LocalVersionFile => $"{SettingsUtil.LocalIl2CppDir}/libil2cpp/hybridclr/generated/libil2cpp-version.txt"; + + private string ReadLocalVersion() + { + if (!File.Exists(LocalVersionFile)) + { + return null; + } + return File.ReadAllText(LocalVersionFile, Encoding.UTF8); + } + + public void WriteLocalVersion() + { + InstalledLibil2cppVersion = PackageVersion; + File.WriteAllText(LocalVersionFile, PackageVersion, Encoding.UTF8); + } + public void InstallDefaultHybridCLR() { InstallFromLocal(PrepareLibil2cppWithHybridclrFromGitRepo()); @@ -237,6 +257,7 @@ namespace HybridCLR.Editor.Installer if (HasInstalledHybridCLR()) { + WriteLocalVersion(); Debug.Log("Install Sucessfully"); } else diff --git a/Editor/Installer/InstallerWindow.cs b/Editor/Installer/InstallerWindow.cs index f1a2b62..178db1e 100644 --- a/Editor/Installer/InstallerWindow.cs +++ b/Editor/Installer/InstallerWindow.cs @@ -46,7 +46,9 @@ namespace HybridCLR.Editor.Installer EditorGUILayout.LabelField($"Package Version: v{_controller.PackageVersion}"); GUILayout.Space(5f); - + EditorGUILayout.LabelField($"Installed libil2cpp Version: {_controller.InstalledLibil2cppVersion ?? "Unknown"}"); + GUILayout.Space(5f); + GUILayout.Space(10f); InstallerController.CompatibleType compatibleType = _controller.GetCompatibleType();