[fix] 修复生成桥接函数时错误使用editor环境的dll,导致NativeArray之类的类型与打包的aot dll不一致,进而生成桥接签名错误的bug。目前直接从裁剪后的AOT dll目录读取,但缺点是需要先build一次生成AOT dll,再生成桥接函数。
parent
5270f307b9
commit
93f855f8ae
|
@ -51,16 +51,22 @@ namespace HybridCLR.Editor.Commands
|
||||||
GenerateMethodBridge(true);
|
GenerateMethodBridge(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static IAssemblyResolver CreateBuildTargetAssemblyResolver(BuildTarget target)
|
||||||
|
{
|
||||||
|
return new CombinedAssemblyResolver(new PathAssemblyResolver(
|
||||||
|
SettingsUtil.GetAssembliesPostIl2CppStripDir(target),
|
||||||
|
SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public static void GenerateMethodBridge(bool compileDll)
|
public static void GenerateMethodBridge(bool compileDll)
|
||||||
{
|
{
|
||||||
// 此处理论会有点问题,打每个平台的时候,都得针对当前平台生成桥接函数
|
BuildTarget target = EditorUserBuildSettings.activeBuildTarget;
|
||||||
// 但影响不大,先这样吧
|
|
||||||
if (compileDll)
|
if (compileDll)
|
||||||
{
|
{
|
||||||
CompileDllCommand.CompileDllActiveBuildTarget();
|
CompileDllCommand.CompileDllActiveBuildTarget();
|
||||||
}
|
}
|
||||||
|
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(CreateBuildTargetAssemblyResolver(target), SettingsUtil.HotUpdateAssemblyNames))
|
||||||
using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), SettingsUtil.HotUpdateAssemblyNames))
|
|
||||||
{
|
{
|
||||||
var analyzer = new Analyzer(new Analyzer.Options
|
var analyzer = new Analyzer(new Analyzer.Options
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,7 +124,7 @@ namespace HybridCLR.Editor.Meta
|
||||||
return new CombinedAssemblyResolver(new PathAssemblyResolver(
|
return new CombinedAssemblyResolver(new PathAssemblyResolver(
|
||||||
SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)),
|
SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)),
|
||||||
new UnityPluginAssemblyResolver(),
|
new UnityPluginAssemblyResolver(),
|
||||||
new UnityAOTAssemblyResolver(),
|
new UnityDotNetAOTAssemblyResolver(),
|
||||||
new UnityEditorAssemblyResolver());
|
new UnityEditorAssemblyResolver());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,25 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace HybridCLR.Editor.Meta
|
namespace HybridCLR.Editor.Meta
|
||||||
{
|
{
|
||||||
public class UnityAOTAssemblyResolver : IAssemblyResolver
|
public class UnityDotNetAOTAssemblyResolver : IAssemblyResolver
|
||||||
{
|
{
|
||||||
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
public string ResolveAssembly(string assemblyName, bool throwExIfNotFind)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
#if !UNITY_2021_1_OR_NEWER
|
||||||
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot/{assemblyName}.dll";
|
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot/{assemblyName}.dll";
|
||||||
|
#else
|
||||||
|
#if UNITY_STANDALONE_WIN
|
||||||
|
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot-win32/{assemblyName}.dll";
|
||||||
|
#elif UNITY_STANDALONE_OSX || UNITY_IOS
|
||||||
|
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot-macos/{assemblyName}.dll";
|
||||||
|
#elif UNITY_STANDALONE_LINUX || UNITY_ANDROID
|
||||||
|
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot-linux/{assemblyName}.dll";
|
||||||
|
#else
|
||||||
|
var assemblyFile = $"{UnityEditor.EditorApplication.applicationContentsPath}/MonoBleedingEdge/lib/mono/unityaot-linux/{assemblyName}.dll";
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
if (File.Exists(assemblyFile))
|
if (File.Exists(assemblyFile))
|
||||||
{
|
{
|
||||||
Debug.Log($"UnityAOTAssemblyResolver.ResolveAssembly:{assemblyFile}");
|
Debug.Log($"UnityAOTAssemblyResolver.ResolveAssembly:{assemblyFile}");
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 029bc0368e1ada342aa29a18d4fae879
|
guid: 87ece9687eaa17648bdc9d2c9bf30520
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "com.focus-creative-games.hybridclr_unity",
|
"name": "com.focus-creative-games.hybridclr_unity",
|
||||||
"version": "1.1.0",
|
"version": "1.1.1",
|
||||||
"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",
|
||||||
|
|
Loading…
Reference in New Issue