AddressableUtils.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using XGame.Framework.i18n;
  2. using XGame.Framework.Quality;
  3. using XGame.Framework.Asset.Addressable.Data;
  4. using System.Collections.Generic;
  5. namespace XGame.Framework.Asset.Addressable
  6. {
  7. public static class AddressableUtils
  8. {
  9. public static void CopyI18nInfos(AddressableI18nInfo[] i18nInfos, ref Dictionary<long, Dictionary<LanguageType, long>> i18nInfoMap)
  10. {
  11. if (i18nInfos == null || i18nInfos.Length == 0)
  12. return;
  13. if (i18nInfoMap == null)
  14. i18nInfoMap = new Dictionary<long, Dictionary<LanguageType, long>>();
  15. foreach (var i18nInfo in i18nInfos)
  16. {
  17. var i18nDatas = i18nInfo.i18nDatas;
  18. if (i18nDatas == null || i18nDatas.Length == 0)
  19. continue;
  20. var langMap = new Dictionary<LanguageType, long>();
  21. foreach (var data in i18nDatas)
  22. {
  23. langMap.Add(data.langFlag, data.addressableId);
  24. }
  25. i18nInfoMap.Add(i18nInfo.addressableId, langMap);
  26. }
  27. }
  28. public static void CopyLodInfos(AddressableLodInfo[] lodInfos, ref Dictionary<long, Dictionary<XQualityLevel, long>> lodInfoMap)
  29. {
  30. if (lodInfos == null || lodInfos.Length == 0)
  31. return;
  32. if (lodInfoMap == null)
  33. lodInfoMap = new Dictionary<long, Dictionary<XQualityLevel, long>>();
  34. foreach (var lodInfo in lodInfos)
  35. {
  36. var lodDatas = lodInfo.lodDatas;
  37. if (lodDatas == null || lodDatas.Length == 0)
  38. continue;
  39. var qualityMap = new Dictionary<XQualityLevel, long>();
  40. foreach (var data in lodDatas)
  41. {
  42. qualityMap.Add(data.quality, data.addressableId);
  43. }
  44. lodInfoMap.Add(lodInfo.addressableId, qualityMap);
  45. }
  46. }
  47. }
  48. }