diff --git a/Editor/Installer/InstallerController.cs b/Editor/Installer/InstallerController.cs index 4f3d956..eb7d22e 100644 --- a/Editor/Installer/InstallerController.cs +++ b/Editor/Installer/InstallerController.cs @@ -93,10 +93,6 @@ namespace HybridCLR.Editor.Installer private static readonly Regex s_unityVersionPat = new Regex(@"(\d+)\.(\d+)\.(\d+)"); - public const int min2020_3_CompatibleMinorVersion = 26; - public const int min2021_3_CompatibleMinorVersion = 0; - public const int min2022_3_CompatibleMinorVersion = 0; - private UnityVersion ParseUnityVersion(string versionStr) { var matches = s_unityVersionPat.Matches(versionStr); @@ -104,9 +100,7 @@ namespace HybridCLR.Editor.Installer { return null; } - // 找最后一个匹配的 Match match = matches[matches.Count - 1]; - // Debug.Log($"capture count:{match.Groups.Count} {match.Groups[1].Value} {match.Groups[2].Value}"); int major = int.Parse(match.Groups[1].Value); int minor1 = int.Parse(match.Groups[2].Value); int minor2 = int.Parse(match.Groups[3].Value); @@ -122,10 +116,10 @@ namespace HybridCLR.Editor.Installer { switch(majorVersion) { - case 2020: return $"2020.3.{min2020_3_CompatibleMinorVersion}"; - case 2021: return $"2021.3.{min2021_3_CompatibleMinorVersion}"; - case 2022: return $"2022.3.{min2022_3_CompatibleMinorVersion}"; - default: return $"2020.3.{min2020_3_CompatibleMinorVersion}"; + case 2020: return $"2020.3.0"; + case 2021: return $"2021.3.0"; + case 2022: return $"2022.3.0"; + default: return $"2020.3.0"; } } @@ -140,22 +134,7 @@ namespace HybridCLR.Editor.Installer { return false; } - switch (version.major) - { - case 2020: - { - return version.minor2 >= min2021_3_CompatibleMinorVersion; - } - case 2021: - { - return version.minor2 >= min2021_3_CompatibleMinorVersion; - } - case 2022: - { - return version.minor2 >= min2022_3_CompatibleMinorVersion; - } - default: throw new Exception($"not support il2cpp_plus branch:{version.major}"); - } + return true; } public string HybridclrLocalVersion => _curDefaultVersion?.hybridclr?.branch; @@ -225,7 +204,7 @@ namespace HybridCLR.Editor.Installer { if (!IsCompatibleVersion()) { - Debug.LogError($"il2cpp 版本不兼容,最小版本为 {GetCurrentUnityVersionMinCompatibleVersionStr()}"); + Debug.LogError($"Incompatible with current version, minimum compatible version: {GetCurrentUnityVersionMinCompatibleVersionStr()}"); return; } string workDir = SettingsUtil.HybridCLRDataDir; @@ -250,11 +229,11 @@ namespace HybridCLR.Editor.Installer if (HasInstalledHybridCLR()) { - Debug.Log("安装成功"); + Debug.Log("Install Sucessfully"); } else { - Debug.LogError("安装失败"); + Debug.LogError("Installation failed!"); } } } diff --git a/Editor/Installer/InstallerWindow.cs b/Editor/Installer/InstallerWindow.cs index 7e1a71f..14eea02 100644 --- a/Editor/Installer/InstallerWindow.cs +++ b/Editor/Installer/InstallerWindow.cs @@ -30,7 +30,7 @@ namespace HybridCLR.Editor.Installer height = 24 }; var content = EditorGUIUtility.IconContent("Settings"); - content.tooltip = "点击打开HybridCLR Settings"; + content.tooltip = "HybridCLR Settings"; if (GUI.Button(rect, content, GUI.skin.GetStyle("IconButton"))) { SettingsService.OpenProjectSettings("Project/HybridCLR Settings"); @@ -41,67 +41,57 @@ namespace HybridCLR.Editor.Installer GUILayout.Space(10f); EditorGUILayout.BeginVertical("box"); - EditorGUILayout.LabelField($"安装状态:{(hasInstall ? "已安装" : "未安装")}", EditorStyles.boldLabel); + EditorGUILayout.LabelField($"Installed: {hasInstall}", EditorStyles.boldLabel); GUILayout.Space(10f); - - EditorGUILayout.LabelField($"{SettingsUtil.PackageName} 版本: v{_controller.PackageVersion}"); - GUILayout.Space(5f); - EditorGUILayout.LabelField($"hybridclr 版本: {_controller.HybridclrLocalVersion}"); - GUILayout.Space(5f); - EditorGUILayout.LabelField($"il2cpp_plus 版本: {_controller.Il2cppPlusLocalVersion}"); + EditorGUILayout.LabelField($"Package Version: v{_controller.PackageVersion}"); GUILayout.Space(5f); GUILayout.Space(10f); if (_controller.IsCompatibleVersion()) { - GUIInstallButton("安装hybridclr+il2cpp_plus代码到本地目录", "安装"); + EditorGUILayout.BeginHorizontal(); + _installFromDir = EditorGUILayout.Toggle("Copy libil2cpp from local", _installFromDir, GUILayout.MinWidth(100)); + EditorGUI.BeginDisabledGroup(!_installFromDir); + EditorGUILayout.TextField(_installLibil2cppWithHybridclrSourceDir, GUILayout.Width(400)); + if (GUILayout.Button("Choose", GUILayout.Width(100))) + { + _installLibil2cppWithHybridclrSourceDir = EditorUtility.OpenFolderPanel("Select libil2cpp", Application.dataPath, "libil2cpp"); + } + EditorGUI.EndDisabledGroup(); + EditorGUILayout.EndHorizontal(); + + GUILayout.Space(20f); + + EditorGUILayout.BeginHorizontal(); + if (GUILayout.Button("Install", GUILayout.Width(100))) + { + InstallLocalHybridCLR(); + GUIUtility.ExitGUI(); + } + EditorGUILayout.EndHorizontal(); } else { - EditorGUILayout.HelpBox($"与当前版本不兼容,最小兼容版本:{_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}", MessageType.Error); + EditorGUILayout.HelpBox($"Incompatible with current version, minimum compatible version:{_controller.GetCurrentUnityVersionMinCompatibleVersionStr()}", MessageType.Error); } EditorGUILayout.EndVertical(); } - private void GUIInstallButton(string content, string button) - { - EditorGUILayout.BeginHorizontal(); - _installFromDir = EditorGUILayout.Toggle("从本地复制libil2cpp", _installFromDir); - EditorGUI.BeginDisabledGroup(!_installFromDir); - EditorGUILayout.TextField(_installLibil2cppWithHybridclrSourceDir, GUILayout.Width(400)); - if (GUILayout.Button("选择目录", GUILayout.Width(100))) - { - _installLibil2cppWithHybridclrSourceDir = EditorUtility.OpenFolderPanel("选择libil2cpp目录", Application.dataPath, "libil2cpp"); - } - EditorGUI.EndDisabledGroup(); - EditorGUILayout.EndHorizontal(); - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField(content); - if (GUILayout.Button(button, GUILayout.Width(100))) - { - InstallLocalHybridCLR(); - GUIUtility.ExitGUI(); - } - EditorGUILayout.EndHorizontal(); - - } - private void InstallLocalHybridCLR() { if (_installFromDir) { if (!Directory.Exists(_installLibil2cppWithHybridclrSourceDir)) { - Debug.LogError($"本地libil2cpp复制目录不存在. '{_installLibil2cppWithHybridclrSourceDir}'"); + Debug.LogError($"Source libil2cpp:'{_installLibil2cppWithHybridclrSourceDir}' doesn't exist."); return; } if (!File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/il2cpp-config.h") || !File.Exists($"{_installLibil2cppWithHybridclrSourceDir}/hybridclr/RuntimeApi.cpp")) { - Debug.LogError($"本地libil2cpp不是合法有效的源码目录. '{_installLibil2cppWithHybridclrSourceDir}'"); + Debug.LogError($"Source libil2cpp:' {_installLibil2cppWithHybridclrSourceDir} ' is invalid"); return; } _controller.InstallFromLocal(_installLibil2cppWithHybridclrSourceDir);