[fix] 修复plugin dll与Unity自带dll同名时,GenerateMethodBridge生成失败的bug

main
walon 2022-09-27 14:57:00 +08:00
parent 07b56fe7e5
commit cd68f33161
5 changed files with 49 additions and 2 deletions

View File

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

View File

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

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c235be11c219a74fa5eb55ed54e7662
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<string> searchPaths = new List<string> { SettingsUtil.GetHotFixDllsOutputDirByTarget(target) };
return new CombinedAssemblyResolver(new PathAssemblyResolver(
SettingsUtil.GetHotFixDllsOutputDirByTarget(target)), new UnityEditorAssemblyResolver());
SettingsUtil.GetHotFixDllsOutputDirByTarget(target)),
new UnityPluginAssemblyResolver(),
new UnityEditorAssemblyResolver());
}
}
}

View File

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