[fix] 修复 UnityPluginAssemblyResolver 搜索依赖dll未检查Plugins外目录的bug
[refactor] 一些重命名 hotfix -> hotUpdate [refactor] HybridCLRGlobalSettings移除 hotUpdateDllOutputDir、 hybridCLRDataDir、strippedAssemblyDir这三个配置项,改为直接写死 [change] Editor下调用LoadMetadataForAOTAssembly返回成功而不是抛出错误main
parent
8eb94be37e
commit
f2ee5e7af1
|
@ -30,7 +30,7 @@ namespace HybridCLR.Editor.Commands
|
|||
|
||||
public static void CompileDll(BuildTarget target)
|
||||
{
|
||||
CompileDll(SettingsUtil.GetHotFixDllsOutputDirByTarget(target), target);
|
||||
CompileDll(SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target), target);
|
||||
}
|
||||
|
||||
[MenuItem("HybridCLR/CompileDll/ActiveBuildTarget", priority = 100)]
|
||||
|
|
|
@ -33,13 +33,4 @@ public class HybridCLRGlobalSettings : ScriptableObject
|
|||
|
||||
[Header("MethodBridge泛型搜索迭代次数")]
|
||||
public int maxMethodBridgeGenericIteration = 4;
|
||||
|
||||
[Header("热更新dll输出目录(相对HybridCLRData目录)")]
|
||||
public string hotUpdateDllOutputDir = "HotUpdateDlls";
|
||||
|
||||
[Header("HybridCLRData目录(相对工程目录)")]
|
||||
public string hybridCLRDataDir = "HybridCLRData";
|
||||
|
||||
[Header("裁剪后的AOT assembly输出目录")]
|
||||
public string strippedAssemblyDir = "AssembliesPostIl2CppStrip";
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace HybridCLR.Editor.Installer
|
|||
$"你所在项目的Unity版本可以与il2cpp_plus版本:{m_Controller.Il2CppBranch} 不一样。\n"
|
||||
+ $"如果你的Unity的版本号 >= {minCompatibleVersion}, 可以直接安装。\n"
|
||||
+ $"如果你的Unity的版本号 < {minCompatibleVersion}, \n"
|
||||
+ $"由于安装HybridCLR时需要从il2cpp_plus对应版本{m_Controller.Il2CppBranch}(而不是你项目版本)拷贝il2cpp目录,\n"
|
||||
+ $"你必须同时安装相应版本 {m_Controller.Il2CppBranch} 才能完成安装", EditorStyles.wordWrappedLabel);
|
||||
+ $"由于安装HybridCLR时需要从il2cpp_plus兼容版本{m_Controller.Il2CppBranch}(而不是你项目版本)拷贝il2cpp目录,\n"
|
||||
+ $"你必须同时安装兼容版本 {m_Controller.Il2CppBranch} 才能完成安装", EditorStyles.wordWrappedLabel);
|
||||
EditorGUILayout.LabelField("==============================================");
|
||||
GUILayout.Space(10f);
|
||||
|
||||
|
@ -38,7 +38,7 @@ namespace HybridCLR.Editor.Installer
|
|||
EditorGUILayout.LabelField($"安装状态:{(m_Controller.HasInstalledHybridCLR() ? "已安装" : "未安装")}", EditorStyles.boldLabel);
|
||||
GUILayout.Space(5f);
|
||||
EditorGUILayout.LabelField($"当前Unity版本: {Application.unityVersion},匹配的il2cpp_plus分支: {m_Controller.Il2CppBranch}");
|
||||
GUISelectUnityDirectory($"il2cpp_plus分支对应Unity版本的il2cpp路径", "Select");
|
||||
GUISelectUnityDirectory($"il2cpp_plus分支对应的Unity兼容版本的il2cpp路径", "Select");
|
||||
GUILayout.Space(10f);
|
||||
GUIInstallButton("安装最新HybridCLR插件代码到本项目", "安装", InitHybridCLR);
|
||||
EditorGUILayout.EndVertical();
|
||||
|
|
|
@ -11,11 +11,24 @@ namespace HybridCLR.Editor.Meta
|
|||
{
|
||||
public class UnityPluginAssemblyResolver : IAssemblyResolver
|
||||
{
|
||||
private static readonly HashSet<string> s_ignoreDirs = new HashSet<string>
|
||||
{
|
||||
"Editor",
|
||||
"StreamingAssets",
|
||||
"Resources",
|
||||
};
|
||||
|
||||
private bool IsPluginDll(string dllPath)
|
||||
{
|
||||
var fileOrDirs = new HashSet<string>(dllPath.Split('\\', '/'));
|
||||
return !fileOrDirs.Intersect(s_ignoreDirs).Any();
|
||||
}
|
||||
|
||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||
{
|
||||
foreach(var dll in Directory.GetFiles(UnityEngine.Application.dataPath, "*.dll", SearchOption.AllDirectories))
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(dll) == assemblyName && dll.Contains("Plugins"))
|
||||
if (Path.GetFileNameWithoutExtension(dll) == assemblyName && IsPluginDll(dll))
|
||||
{
|
||||
Debug.Log($"plugin:{dll}");
|
||||
return dll;
|
||||
|
|
|
@ -85,7 +85,7 @@ namespace HybridCLR.Editor
|
|||
public static IAssemblyResolver CreateBuildTargetAssemblyResolver(UnityEditor.BuildTarget target)
|
||||
{
|
||||
return new CombinedAssemblyResolver(new PathAssemblyResolver(
|
||||
SettingsUtil.GetHotFixDllsOutputDirByTarget(target)),
|
||||
SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)),
|
||||
new UnityPluginAssemblyResolver(),
|
||||
new UnityEditorAssemblyResolver());
|
||||
}
|
||||
|
|
|
@ -28,11 +28,11 @@ namespace HybridCLR.Editor
|
|||
|
||||
public static string Dataunity3dBinFile { get; } = "data.unity3d";
|
||||
|
||||
public static string HotFixDllsOutputDir => $"{HybridCLRDataDir}/{GlobalSettings.hotUpdateDllOutputDir}";
|
||||
public static string HotUpdateDllsRootOutputDir => $"{HybridCLRDataDir}/HotUpdateDlls";
|
||||
|
||||
public static string HybridCLRDataDir => $"{ProjectDir}/{GlobalSettings.hybridCLRDataDir}";
|
||||
public static string HybridCLRDataDir => $"{ProjectDir}/HybridCLRData";
|
||||
|
||||
public static string AssembliesPostIl2CppStripDir => $"{HybridCLRDataDir}/{GlobalSettings.strippedAssemblyDir}";
|
||||
public static string AssembliesPostIl2CppStripDir => $"{HybridCLRDataDir}/AssembliesPostIl2CppStrip";
|
||||
|
||||
public static string LocalUnityDataDir => $"{HybridCLRDataDir}/LocalIl2CppData-{Application.platform}";
|
||||
|
||||
|
@ -42,9 +42,9 @@ namespace HybridCLR.Editor
|
|||
|
||||
public static string Il2CppBuildCacheDir { get; } = $"{ProjectDir}/Library/Il2cppBuildCache";
|
||||
|
||||
public static string GetHotFixDllsOutputDirByTarget(BuildTarget target)
|
||||
public static string GetHotUpdateDllsOutputDirByTarget(BuildTarget target)
|
||||
{
|
||||
return $"{HotFixDllsOutputDir}/{target}";
|
||||
return $"{HotUpdateDllsRootOutputDir}/{target}";
|
||||
}
|
||||
|
||||
public static string GetAssembliesPostIl2CppStripDir(BuildTarget target)
|
||||
|
|
|
@ -18,10 +18,16 @@ namespace HybridCLR
|
|||
private const string dllName = "il2cpp";
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 加载补充元数据assembly
|
||||
/// </summary>
|
||||
/// <param name="dllBytes"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotSupportedException"></exception>
|
||||
public static unsafe LoadImageErrorCode LoadMetadataForAOTAssembly(byte[] dllBytes)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
throw new NotSupportedException("LoadMetadataForAOTAssembly can only be invoked in il2cpp");
|
||||
return LoadImageErrorCode.OK;
|
||||
#else
|
||||
fixed(byte* data = dllBytes)
|
||||
{
|
||||
|
@ -30,18 +36,40 @@ namespace HybridCLR
|
|||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载补充元数据assembly
|
||||
/// </summary>
|
||||
/// <param name="dllBytes"></param>
|
||||
/// <param name="dllSize"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_LoadMetadataForAOTAssembly")]
|
||||
public static extern int LoadMetadataForAOTAssembly(IntPtr dllBytes, int dllSize);
|
||||
|
||||
/// <summary>
|
||||
/// 获取解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_GetInterpreterThreadObjectStackSize")]
|
||||
public static extern int GetInterpreterThreadObjectStackSize();
|
||||
|
||||
/// <summary>
|
||||
/// 设置解释器线程栈的最大StackObject个数(size*8 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_SetInterpreterThreadObjectStackSize")]
|
||||
public static extern void SetInterpreterThreadObjectStackSize(int size);
|
||||
|
||||
/// <summary>
|
||||
/// 获取解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_GetInterpreterThreadFrameStackSize")]
|
||||
public static extern int GetInterpreterThreadFrameStackSize();
|
||||
|
||||
/// <summary>
|
||||
/// 设置解释器线程函数帧数量(sizeof(InterpreterFrame)*size 为最终占用的内存大小)
|
||||
/// </summary>
|
||||
/// <param name="size"></param>
|
||||
[DllImport(dllName, EntryPoint = "RuntimeApi_SetInterpreterThreadFrameStackSize")]
|
||||
public static extern void SetInterpreterThreadFrameStackSize(int size);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "com.focus-creative-games.hybridclr_unity",
|
||||
"version": "0.3.4",
|
||||
"version": "0.3.5",
|
||||
"displayName": "HybridCLR",
|
||||
"description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR",
|
||||
"category": "Runtime",
|
||||
|
|
Loading…
Reference in New Issue