ResourceBuilderController.ResourceData.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using System.Collections.Generic;
  8. namespace UnityGameFramework.Editor.ResourceTools
  9. {
  10. public sealed partial class ResourceBuilderController
  11. {
  12. private sealed class ResourceData
  13. {
  14. private readonly string m_Name;
  15. private readonly string m_Variant;
  16. private readonly string m_FileSystem;
  17. private readonly LoadType m_LoadType;
  18. private readonly bool m_Packed;
  19. private readonly string[] m_ResourceGroups;
  20. private readonly List<AssetData> m_AssetDatas;
  21. private readonly List<ResourceCode> m_Codes;
  22. public ResourceData(string name, string variant, string fileSystem, LoadType loadType, bool packed, string[] resourceGroups)
  23. {
  24. m_Name = name;
  25. m_Variant = variant;
  26. m_FileSystem = fileSystem;
  27. m_LoadType = loadType;
  28. m_Packed = packed;
  29. m_ResourceGroups = resourceGroups;
  30. m_AssetDatas = new List<AssetData>();
  31. m_Codes = new List<ResourceCode>();
  32. }
  33. public string Name
  34. {
  35. get
  36. {
  37. return m_Name;
  38. }
  39. }
  40. public string Variant
  41. {
  42. get
  43. {
  44. return m_Variant;
  45. }
  46. }
  47. public string FileSystem
  48. {
  49. get
  50. {
  51. return m_FileSystem;
  52. }
  53. }
  54. public bool IsLoadFromBinary
  55. {
  56. get
  57. {
  58. return m_LoadType == LoadType.LoadFromBinary || m_LoadType == LoadType.LoadFromBinaryAndQuickDecrypt || m_LoadType == LoadType.LoadFromBinaryAndDecrypt;
  59. }
  60. }
  61. public LoadType LoadType
  62. {
  63. get
  64. {
  65. return m_LoadType;
  66. }
  67. }
  68. public bool Packed
  69. {
  70. get
  71. {
  72. return m_Packed;
  73. }
  74. }
  75. public int AssetCount
  76. {
  77. get
  78. {
  79. return m_AssetDatas.Count;
  80. }
  81. }
  82. public string[] GetResourceGroups()
  83. {
  84. return m_ResourceGroups;
  85. }
  86. public string[] GetAssetGuids()
  87. {
  88. string[] assetGuids = new string[m_AssetDatas.Count];
  89. for (int i = 0; i < m_AssetDatas.Count; i++)
  90. {
  91. assetGuids[i] = m_AssetDatas[i].Guid;
  92. }
  93. return assetGuids;
  94. }
  95. public string[] GetAssetNames()
  96. {
  97. string[] assetNames = new string[m_AssetDatas.Count];
  98. for (int i = 0; i < m_AssetDatas.Count; i++)
  99. {
  100. assetNames[i] = m_AssetDatas[i].Name;
  101. }
  102. return assetNames;
  103. }
  104. public AssetData[] GetAssetDatas()
  105. {
  106. return m_AssetDatas.ToArray();
  107. }
  108. public AssetData GetAssetData(string assetName)
  109. {
  110. foreach (AssetData assetData in m_AssetDatas)
  111. {
  112. if (assetData.Name == assetName)
  113. {
  114. return assetData;
  115. }
  116. }
  117. return null;
  118. }
  119. public void AddAssetData(string guid, string name, int length, int hashCode, string[] dependencyAssetNames)
  120. {
  121. m_AssetDatas.Add(new AssetData(guid, name, length, hashCode, dependencyAssetNames));
  122. }
  123. public ResourceCode GetCode(Platform platform)
  124. {
  125. foreach (ResourceCode code in m_Codes)
  126. {
  127. if (code.Platform == platform)
  128. {
  129. return code;
  130. }
  131. }
  132. return null;
  133. }
  134. public ResourceCode[] GetCodes()
  135. {
  136. return m_Codes.ToArray();
  137. }
  138. public void AddCode(Platform platform, int length, int hashCode, int compressedLength, int compressedHashCode)
  139. {
  140. m_Codes.Add(new ResourceCode(platform, length, hashCode, compressedLength, compressedHashCode));
  141. }
  142. }
  143. }
  144. }