[opt] 当Installer中il2cpp路径不包含版本号时,给出提示

[opt] 新增 LoadMetadataForAOTAssembly(byte[])函数,简化使用。同时在Editor下被意外调用时给出更清晰的信息
main
walon 2022-09-28 21:48:09 +08:00
parent a56f940890
commit f810ac53ba
4 changed files with 37 additions and 17 deletions

View File

@ -18,6 +18,7 @@ namespace HybridCLR.Editor.Installer
public enum InstallErrorCode public enum InstallErrorCode
{ {
Ok, Ok,
InvalidUnityInstallPath,
Il2CppInstallPathNotMatchIl2CppBranch, Il2CppInstallPathNotMatchIl2CppBranch,
Il2CppInstallPathNotExists, Il2CppInstallPathNotExists,
NotIl2CppPath, NotIl2CppPath,
@ -233,7 +234,9 @@ namespace HybridCLR.Editor.Installer
if (!IsComaptibleWithIl2CppPlusBranch(il2cppBranch, installDir)) if (!IsComaptibleWithIl2CppPlusBranch(il2cppBranch, installDir))
{ {
return InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch; return TryParseMinorVersion(installDir, out _) ?
InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch
: InstallErrorCode.InvalidUnityInstallPath;
} }
if (!installDir.EndsWith("/il2cpp")) if (!installDir.EndsWith("/il2cpp"))

View File

@ -87,6 +87,11 @@ namespace HybridCLR.Editor.Installer
EditorGUILayout.HelpBox("li2cpp 路径不存在", MessageType.Error); EditorGUILayout.HelpBox("li2cpp 路径不存在", MessageType.Error);
break; break;
} }
case InstallErrorCode.InvalidUnityInstallPath:
{
EditorGUILayout.HelpBox($"Unity安装目录必须包含版本号否则无法识别版本", MessageType.Error);
break;
}
case InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch: case InstallErrorCode.Il2CppInstallPathNotMatchIl2CppBranch:
{ {
EditorGUILayout.HelpBox($"il2cpp 版本不兼容,最小版本为 {m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch)}", MessageType.Error); EditorGUILayout.HelpBox($"il2cpp 版本不兼容,最小版本为 {m_Controller.GetMinCompatibleVersion(m_Controller.Il2CppBranch)}", MessageType.Error);

View File

@ -18,6 +18,18 @@ namespace HybridCLR
private const string dllName = "il2cpp"; private const string dllName = "il2cpp";
#endif #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")] [DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")]
public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize); public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize);

View File

@ -1,6 +1,6 @@
{ {
"name": "com.focus-creative-games.hybridclr_unity", "name": "com.focus-creative-games.hybridclr_unity",
"version": "0.3.3", "version": "0.3.4",
"displayName": "HybridCLR", "displayName": "HybridCLR",
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
"category": "Runtime", "category": "Runtime",