PathAssemblyResolver.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using UnityEngine;
  8. namespace HybridCLR.Editor.Meta
  9. {
  10. public class PathAssemblyResolver : AssemblyResolverBase
  11. {
  12. private readonly string[] _searchPaths;
  13. public PathAssemblyResolver(params string[] searchPaths)
  14. {
  15. _searchPaths = searchPaths;
  16. }
  17. protected override bool TryResolveAssembly(string assemblyName, out string assemblyPath)
  18. {
  19. foreach(var path in _searchPaths)
  20. {
  21. assemblyPath = Path.Combine(path, $"{assemblyName}.dll");
  22. if (File.Exists(assemblyPath))
  23. {
  24. Debug.Log($"resolve {assemblyName} at {assemblyPath}");
  25. return true;
  26. }
  27. assemblyPath = Path.Combine(path, $"{assemblyName}.dll.bytes");
  28. if (File.Exists(assemblyPath))
  29. {
  30. Debug.Log($"resolve {assemblyName} at {assemblyPath}");
  31. return true;
  32. }
  33. }
  34. assemblyPath = null;
  35. return false;
  36. }
  37. }
  38. }