diff --git a/Editor/Installer/InstallerController.cs b/Editor/Installer/InstallerController.cs index e67793c..72730f2 100644 --- a/Editor/Installer/InstallerController.cs +++ b/Editor/Installer/InstallerController.cs @@ -18,6 +18,7 @@ namespace HybridCLR.Editor.Installer public enum InstallErrorCode { Ok, + InvalidUnityInstallPath, Il2CppInstallPathNotMatchIl2CppBranch, Il2CppInstallPathNotExists, NotIl2CppPath, @@ -233,7 +234,9 @@ namespace HybridCLR.Editor.Installer if (!IsComaptibleWithIl2CppPlusBranch(il2cppBranch, installDir)) { - return InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch; + return TryParseMinorVersion(installDir, out _) ? + InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch + : InstallErrorCode.InvalidUnityInstallPath; } if (!installDir.EndsWith("/il2cpp")) diff --git a/Editor/Installer/InstallerWindow.cs b/Editor/Installer/InstallerWindow.cs index d5fd6ac..07ff58b 100644 --- a/Editor/Installer/InstallerWindow.cs +++ b/Editor/Installer/InstallerWindow.cs @@ -79,24 +79,29 @@ namespace HybridCLR.Editor.Installer switch (err) { case InstallErrorCode.Ok: - { - break; - } + { + break; + } case InstallErrorCode.Il2CppInstallPathNotExists: - { - EditorGUILayout.HelpBox("li2cpp 路径不存在", MessageType.Error); - break; - } + { + EditorGUILayout.HelpBox("li2cpp 路径不存在", MessageType.Error); + break; + } + case InstallErrorCode.InvalidUnityInstallPath: + { + EditorGUILayout.HelpBox($"Unity安装目录必须包含版本号,否则无法识别版本", MessageType.Error); + break; + } case InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch: - { - EditorGUILayout.HelpBox($"il2cpp 版本不兼容,最小版本为 {m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch)}", MessageType.Error); - break; - } + { + EditorGUILayout.HelpBox($"il2cpp 版本不兼容,最小版本为 {m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch)}", MessageType.Error); + break; + } case InstallErrorCode.NotIl2CppPath: - { - EditorGUILayout.HelpBox($"当前选择的路径不是il2cpp目录(必须类似 xxx/il2cpp)", MessageType.Error); - break; - } + { + EditorGUILayout.HelpBox($"当前选择的路径不是il2cpp目录(必须类似 xxx/il2cpp)", MessageType.Error); + break; + } default: throw new Exception($"not support {err}"); } } diff --git a/Runtime/RuntimeApi.cs b/Runtime/RuntimeApi.cs index 417c737..84552c8 100644 --- a/Runtime/RuntimeApi.cs +++ b/Runtime/RuntimeApi.cs @@ -18,6 +18,18 @@ namespace HybridCLR private const string dllName = "il2cpp"; #endif + public static unsafe LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes) + { +#if UNITY_EDITOR + throw new NotSupportedException("LoadMetadataForAOTAssembly can only be invoked in il2cpp"); +#else + fixed(byte* data = dllBytes) + { + return (LoadImageErrorCode)LoadMetadataForAOTAssembly((IntPtr)data, dllBytes.Length); + } +#endif + } + [DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")] public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize); diff --git a/package.json b/package.json index 1261e6a..a94c781 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "0.3.3", + "version": "0.3.4", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",