DefaultAddressRule.cs 1010 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.IO;
  2. namespace YooAsset.Editor
  3. {
  4. /// <summary>
  5. /// 以文件名为定位地址
  6. /// </summary>
  7. public class AddressByFileName : IAddressRule
  8. {
  9. string IAddressRule.GetAssetAddress(AddressRuleData data)
  10. {
  11. return Path.GetFileNameWithoutExtension(data.AssetPath);
  12. }
  13. }
  14. /// <summary>
  15. /// 以组名+文件名为定位地址
  16. /// </summary>
  17. public class AddressByGroupAndFileName : IAddressRule
  18. {
  19. string IAddressRule.GetAssetAddress(AddressRuleData data)
  20. {
  21. string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
  22. return $"{data.GroupName}_{fileName}";
  23. }
  24. }
  25. /// <summary>
  26. /// 以收集器名+文件名为定位地址
  27. /// </summary>
  28. public class AddressByCollectorAndFileName : IAddressRule
  29. {
  30. string IAddressRule.GetAssetAddress(AddressRuleData data)
  31. {
  32. string fileName = Path.GetFileNameWithoutExtension(data.AssetPath);
  33. string collectorName = Path.GetFileNameWithoutExtension(data.CollectPath);
  34. return $"{collectorName}_{fileName}";
  35. }
  36. }
  37. }