hybridclr_unity/Editor/Meta/PathAssemblyResolver.cs

36 lines
991 B
C#
Raw Normal View History

2022-09-22 08:56:07 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace HybridCLR.Editor.Meta
{
public class PathAssemblyResolver : AssemblyResolverBase
2022-09-22 08:56:07 +08:00
{
private readonly string[] _searchPaths;
public PathAssemblyResolver(params string[] searchPaths)
{
_searchPaths = searchPaths;
}
protected override bool TryResolveAssembly(string assemblyName, out string assemblyPath)
2022-09-22 08:56:07 +08:00
{
foreach(var path in _searchPaths)
{
string assPath = Path.Combine(path, assemblyName + ".dll");
if (File.Exists(assPath))
{
Debug.Log($"resolve {assemblyName} at {assPath}");
assemblyPath = assPath;
return true;
2022-09-22 08:56:07 +08:00
}
}
assemblyPath = null;
return false;
2022-09-22 08:56:07 +08:00
}
}
}