DefaultUnpackRemoteServices.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections.Generic;
  2. namespace YooAsset
  3. {
  4. internal class DefaultUnpackRemoteServices : IRemoteServices
  5. {
  6. private readonly string _buildinPackageRoot;
  7. protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
  8. public DefaultUnpackRemoteServices(string buildinPackRoot)
  9. {
  10. _buildinPackageRoot = buildinPackRoot;
  11. }
  12. string IRemoteServices.GetRemoteMainURL(string fileName)
  13. {
  14. return GetFileLoadURL(fileName);
  15. }
  16. string IRemoteServices.GetRemoteFallbackURL(string fileName)
  17. {
  18. return GetFileLoadURL(fileName);
  19. }
  20. private string GetFileLoadURL(string fileName)
  21. {
  22. if (_mapping.TryGetValue(fileName, out string url) == false)
  23. {
  24. string filePath = PathUtility.Combine(_buildinPackageRoot, fileName);
  25. url = DownloadSystemHelper.ConvertToWWWPath(filePath);
  26. _mapping.Add(fileName, url);
  27. }
  28. return url;
  29. }
  30. }
  31. }