DependencyData.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 class DependencyData
  11. {
  12. private List<Resource> m_DependencyResources;
  13. private List<Asset> m_DependencyAssets;
  14. private List<string> m_ScatteredDependencyAssetNames;
  15. public DependencyData()
  16. {
  17. m_DependencyResources = new List<Resource>();
  18. m_DependencyAssets = new List<Asset>();
  19. m_ScatteredDependencyAssetNames = new List<string>();
  20. }
  21. public int DependencyResourceCount
  22. {
  23. get
  24. {
  25. return m_DependencyResources.Count;
  26. }
  27. }
  28. public int DependencyAssetCount
  29. {
  30. get
  31. {
  32. return m_DependencyAssets.Count;
  33. }
  34. }
  35. public int ScatteredDependencyAssetCount
  36. {
  37. get
  38. {
  39. return m_ScatteredDependencyAssetNames.Count;
  40. }
  41. }
  42. public void AddDependencyAsset(Asset asset)
  43. {
  44. if (!m_DependencyResources.Contains(asset.Resource))
  45. {
  46. m_DependencyResources.Add(asset.Resource);
  47. }
  48. m_DependencyAssets.Add(asset);
  49. }
  50. public void AddScatteredDependencyAsset(string dependencyAssetName)
  51. {
  52. m_ScatteredDependencyAssetNames.Add(dependencyAssetName);
  53. }
  54. public Resource[] GetDependencyResources()
  55. {
  56. return m_DependencyResources.ToArray();
  57. }
  58. public Asset[] GetDependencyAssets()
  59. {
  60. return m_DependencyAssets.ToArray();
  61. }
  62. public string[] GetScatteredDependencyAssetNames()
  63. {
  64. return m_ScatteredDependencyAssetNames.ToArray();
  65. }
  66. public void RefreshData()
  67. {
  68. m_DependencyResources.Sort(DependencyResourcesComparer);
  69. m_DependencyAssets.Sort(DependencyAssetsComparer);
  70. m_ScatteredDependencyAssetNames.Sort();
  71. }
  72. private int DependencyResourcesComparer(Resource a, Resource b)
  73. {
  74. return a.FullName.CompareTo(b.FullName);
  75. }
  76. private int DependencyAssetsComparer(Asset a, Asset b)
  77. {
  78. return a.Name.CompareTo(b.Name);
  79. }
  80. }
  81. }