UpdatableVersionList.Asset.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 Jiang Yin. All rights reserved.
  4. // Homepage: https://gameframework.cn/
  5. // Feedback: mailto:ellan@gameframework.cn
  6. //------------------------------------------------------------
  7. using System.Runtime.InteropServices;
  8. namespace GameFramework.Resource
  9. {
  10. public partial struct UpdatableVersionList
  11. {
  12. /// <summary>
  13. /// 资源。
  14. /// </summary>
  15. [StructLayout(LayoutKind.Auto)]
  16. public struct Asset
  17. {
  18. private static readonly int[] EmptyIntArray = new int[] { };
  19. private readonly string m_Name;
  20. private readonly int[] m_DependencyAssetIndexes;
  21. /// <summary>
  22. /// 初始化资源的新实例。
  23. /// </summary>
  24. /// <param name="name">资源名称。</param>
  25. /// <param name="dependencyAssetIndexes">资源包含的依赖资源索引集合。</param>
  26. public Asset(string name, int[] dependencyAssetIndexes)
  27. {
  28. if (string.IsNullOrEmpty(name))
  29. {
  30. throw new GameFrameworkException("Name is invalid.");
  31. }
  32. m_Name = name;
  33. m_DependencyAssetIndexes = dependencyAssetIndexes ?? EmptyIntArray;
  34. }
  35. /// <summary>
  36. /// 获取资源名称。
  37. /// </summary>
  38. public string Name
  39. {
  40. get
  41. {
  42. return m_Name;
  43. }
  44. }
  45. /// <summary>
  46. /// 获取资源包含的依赖资源索引集合。
  47. /// </summary>
  48. /// <returns>资源包含的依赖资源索引集合。</returns>
  49. public int[] GetDependencyAssetIndexes()
  50. {
  51. return m_DependencyAssetIndexes;
  52. }
  53. }
  54. }
  55. }