[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
{
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"))

View File

@ -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}");
}
}

View File

@ -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);

View File

@ -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",