2022-09-27 14:57:00 +08:00
|
|
|
|
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))
|
|
|
|
|
{
|
2022-09-27 16:12:34 +08:00
|
|
|
|
if (Path.GetFileNameWithoutExtension(dll) == assemblyName && dll.Contains("Plugins"))
|
2022-09-27 14:57:00 +08:00
|
|
|
|
{
|
|
|
|
|
Debug.Log($"plugin:{dll}");
|
|
|
|
|
return dll;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (throwExIfNotFind)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"resolve assembly:{assemblyName} fail");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|