diff --git a/Editor/Commands/MethodBridgeGeneratorCommand.cs b/Editor/Commands/MethodBridgeGeneratorCommand.cs index 4c092b2..3d33549 100644 --- a/Editor/Commands/MethodBridgeGeneratorCommand.cs +++ b/Editor/Commands/MethodBridgeGeneratorCommand.cs @@ -51,16 +51,22 @@ namespace HybridCLR.Editor.Commands GenerateMethodBridge(true); } + static IAssemblyResolver CreateBuildTargetAssemblyResolver(BuildTarget target) + { + return new CombinedAssemblyResolver(new PathAssemblyResolver( + SettingsUtil.GetAssembliesPostIl2CppStripDir(target), + SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)) + ); + } + public static void GenerateMethodBridge(bool compileDll) { - // 此处理论会有点问题,打每个平台的时候,都得针对当前平台生成桥接函数 - // 但影响不大,先这样吧 + BuildTarget target = EditorUserBuildSettings.activeBuildTarget; if (compileDll) { CompileDllCommand.CompileDllActiveBuildTarget(); } - - using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(MetaUtil.CreateBuildTargetAssemblyResolver(EditorUserBuildSettings.activeBuildTarget), SettingsUtil.HotUpdateAssemblyNames)) + using (AssemblyReferenceDeepCollector collector = new AssemblyReferenceDeepCollector(CreateBuildTargetAssemblyResolver(target), SettingsUtil.HotUpdateAssemblyNames)) { var analyzer = new Analyzer(new Analyzer.Options { diff --git a/Editor/Meta/MetaUtil.cs b/Editor/Meta/MetaUtil.cs index 45983ab..167cc15 100644 --- a/Editor/Meta/MetaUtil.cs +++ b/Editor/Meta/MetaUtil.cs @@ -124,7 +124,7 @@ namespace HybridCLR.Editor.Meta return new CombinedAssemblyResolver(new PathAssemblyResolver( SettingsUtil.GetHotUpdateDllsOutputDirByTarget(target)), new UnityPluginAssemblyResolver(), - new UnityAOTAssemblyResolver(), + new UnityDotNetAOTAssemblyResolver(), new UnityEditorAssemblyResolver()); } } diff --git a/Editor/Meta/UnityAOTAssemblyResolver.cs b/Editor/Meta/UnityDotNetAOTAssemblyResolver.cs similarity index 50% rename from Editor/Meta/UnityAOTAssemblyResolver.cs rename to Editor/Meta/UnityDotNetAOTAssemblyResolver.cs index fcd0319..b8df2a6 100644 --- a/Editor/Meta/UnityAOTAssemblyResolver.cs +++ b/Editor/Meta/UnityDotNetAOTAssemblyResolver.cs @@ -9,12 +9,25 @@ using UnityEngine; namespace HybridCLR.Editor.Meta { - public class UnityAOTAssemblyResolver : IAssemblyResolver + public class UnityDotNetAOTAssemblyResolver : IAssemblyResolver { public string ResolveAssembly(string assemblyName, bool throwExIfNotFind) { // +#if !UNITY_2021_1_OR_NEWER 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)) { Debug.Log($"UnityAOTAssemblyResolver.ResolveAssembly:{assemblyFile}"); diff --git a/Editor/Meta/UnityAOTAssemblyResolver.cs.meta b/Editor/Meta/UnityDotNetAOTAssemblyResolver.cs.meta similarity index 83% rename from Editor/Meta/UnityAOTAssemblyResolver.cs.meta rename to Editor/Meta/UnityDotNetAOTAssemblyResolver.cs.meta index 8fb10f3..ce41f39 100644 --- a/Editor/Meta/UnityAOTAssemblyResolver.cs.meta +++ b/Editor/Meta/UnityDotNetAOTAssemblyResolver.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 029bc0368e1ada342aa29a18d4fae879 +guid: 87ece9687eaa17648bdc9d2c9bf30520 MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/package.json b/package.json index 0f00897..1ee9382 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "1.1.0", + "version": "1.1.1", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",