AssetInfo.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using XGame.Framework.Serialization;
  2. using System;
  3. namespace XGame.Framework.Asset.Addressable.Data
  4. {
  5. [Serializable]
  6. public struct AssetInfo : IComparable, ISerializable
  7. {
  8. /// <summary>
  9. /// id,资源管理内部使用id标识
  10. /// </summary>
  11. public long addressableId;
  12. /// <summary>
  13. /// 名字,资源对外的唯一标识
  14. /// </summary>
  15. public string addressableName;
  16. public string assetGUID;
  17. //public AddressableAssetType assetType;
  18. /// <summary>
  19. /// Resources下的资源才会赋值
  20. /// </summary>
  21. public string relativePath;
  22. ///// <summary>
  23. ///// 兼容旧代码,以后要删除
  24. ///// </summary>
  25. //public string tempPath;
  26. public override string ToString()
  27. {
  28. return $"Asset id:{addressableId} key:{addressableName} guid:{assetGUID} path:{relativePath}";
  29. }
  30. public int CompareTo(object obj)
  31. {
  32. if (obj is AssetInfo compareInfo)
  33. {
  34. return string.CompareOrdinal(this.addressableName, compareInfo.addressableName);
  35. }
  36. return -1;
  37. }
  38. void ISerializable.Serialize(IWriter writer)
  39. {
  40. writer.Write(addressableId);
  41. writer.Write(addressableName);
  42. writer.Write(assetGUID);
  43. writer.Write(relativePath);
  44. }
  45. void ISerializable.Deserialize(IReader reader)
  46. {
  47. addressableId = reader.ReadLong();
  48. addressableName = reader.ReadString();
  49. assetGUID = reader.ReadString();
  50. relativePath = reader.ReadString();
  51. }
  52. }
  53. }