PathAssemblyResolver.cs 991 B

1234567891011121314151617181920212223242526272829303132333435
  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. string assPath = Path.Combine(path, assemblyName + ".dll");
  22. if (File.Exists(assPath))
  23. {
  24. Debug.Log($"resolve {assemblyName} at {assPath}");
  25. assemblyPath = assPath;
  26. return true;
  27. }
  28. }
  29. assemblyPath = null;
  30. return false;
  31. }
  32. }
  33. }