From cd68f3316120577e47082fdd4b8d0a4fcc05d163 Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 27 Sep 2022 14:57:00 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E4=BF=AE=E5=A4=8Dplugin=20dll=E4=B8=8E?= =?UTF-8?q?Unity=E8=87=AA=E5=B8=A6dll=E5=90=8C=E5=90=8D=E6=97=B6=EF=BC=8CG?= =?UTF-8?q?enerateMethodBridge=E7=94=9F=E6=88=90=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Editor/Commands/CompileDllCommand.cs | 1 + Editor/Meta/UnityPluginAssemblyResolver.cs | 31 +++++++++++++++++++ .../Meta/UnityPluginAssemblyResolver.cs.meta | 11 +++++++ Editor/MetaUtil.cs | 6 +++- package.json | 2 +- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 Editor/Meta/UnityPluginAssemblyResolver.cs create mode 100644 Editor/Meta/UnityPluginAssemblyResolver.cs.meta diff --git a/Editor/Commands/CompileDllCommand.cs b/Editor/Commands/CompileDllCommand.cs index c3d9547..4bc95c8 100644 --- a/Editor/Commands/CompileDllCommand.cs +++ b/Editor/Commands/CompileDllCommand.cs @@ -25,6 +25,7 @@ namespace HybridCLR.Editor.Commands { //Debug.LogFormat("compile assemblies:{1}/{0}", ass, buildDir); } + Debug.Log("compile finish!!!"); } public static void CompileDll(BuildTarget target) diff --git a/Editor/Meta/UnityPluginAssemblyResolver.cs b/Editor/Meta/UnityPluginAssemblyResolver.cs new file mode 100644 index 0000000..c77c0b0 --- /dev/null +++ b/Editor/Meta/UnityPluginAssemblyResolver.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; + +namespace HybridCLR.Editor.Meta +{ + public class UnityPluginAssemblyResolver : IAssemblyResolver + { + public string ResolveAssembly(string assemblyName, bool throwExIfNotFind) + { + foreach(var dll in Directory.GetFiles(UnityEngine.Application.dataPath, "*.dll", SearchOption.AllDirectories)) + { + if (Path.GetFileNameWithoutExtension(dll) == assemblyName) + { + Debug.Log($"plugin:{dll}"); + return dll; + } + } + if (throwExIfNotFind) + { + throw new Exception($"resolve assembly:{assemblyName} fail"); + } + return null; + } + } +} diff --git a/Editor/Meta/UnityPluginAssemblyResolver.cs.meta b/Editor/Meta/UnityPluginAssemblyResolver.cs.meta new file mode 100644 index 0000000..707e174 --- /dev/null +++ b/Editor/Meta/UnityPluginAssemblyResolver.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6c235be11c219a74fa5eb55ed54e7662 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/MetaUtil.cs b/Editor/MetaUtil.cs index 0b5aab0..78d4e95 100644 --- a/Editor/MetaUtil.cs +++ b/Editor/MetaUtil.cs @@ -2,6 +2,7 @@ using HybridCLR.Editor.Meta; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -83,8 +84,11 @@ namespace HybridCLR.Editor public static IAssemblyResolver CreateBuildTargetAssemblyResolver(UnityEditor.BuildTarget target) { + List searchPaths = new List { SettingsUtil.GetHotFixDllsOutputDirByTarget(target) }; return new CombinedAssemblyResolver(new PathAssemblyResolver( - SettingsUtil.GetHotFixDllsOutputDirByTarget(target)), new UnityEditorAssemblyResolver()); + SettingsUtil.GetHotFixDllsOutputDirByTarget(target)), + new UnityPluginAssemblyResolver(), + new UnityEditorAssemblyResolver()); } } } diff --git a/package.json b/package.json index b4bd2ba..151a139 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "0.3.0", + "version": "0.3.1", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",