ABDataSource.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using UnityEditor;
  2. using System;
  3. namespace AssetBundleBrowser.AssetBundleDataSource
  4. {
  5. /// <summary>
  6. /// Build Info struct used by ABDataSource to pass needed build data around.
  7. /// </summary>
  8. public partial class ABBuildInfo
  9. {
  10. /// <summary>
  11. /// Directory to place build result
  12. /// </summary>
  13. public string outputDirectory
  14. {
  15. get { return m_outputDirectory; }
  16. set { m_outputDirectory = value; }
  17. }
  18. private string m_outputDirectory;
  19. /// <summary>
  20. /// Standard asset bundle build options.
  21. /// </summary>
  22. public BuildAssetBundleOptions options
  23. {
  24. get { return m_options; }
  25. set { m_options = value; }
  26. }
  27. private BuildAssetBundleOptions m_options;
  28. /// <summary>
  29. /// Target platform for build.
  30. /// </summary>
  31. public BuildTarget buildTarget
  32. {
  33. get { return m_buildTarget; }
  34. set { m_buildTarget = value; }
  35. }
  36. private BuildTarget m_buildTarget;
  37. /// <summary>
  38. /// Callback for build event.
  39. /// </summary>
  40. public Action<string> onBuild
  41. {
  42. get { return m_onBuild; }
  43. set { m_onBuild = value; }
  44. }
  45. private Action<string> m_onBuild;
  46. }
  47. /// <summary>
  48. /// Interface class used by browser. It is expected to contain all information needed to display predicted bundle layout.
  49. /// Any class deriving from this interface AND imlementing CreateDataSources() will be picked up by the browser automatically
  50. /// and displayed in an in-tool dropdown. By default, that dropdown is hidden if the browser detects no external data sources.
  51. /// To turn it on, right click on tab header "AssetBUndles" and enable "Custom Sources"
  52. ///
  53. /// Must implement CreateDataSources() to be picked up by the browser.
  54. /// public static List<ABDataSource> CreateDataSources();
  55. ///
  56. /// </summary>
  57. public partial interface ABDataSource
  58. {
  59. //// all derived classes must implement the following interface in order to be picked up by the browser.
  60. //public static List<ABDataSource> CreateDataSources();
  61. /// <summary>
  62. /// Name of DataSource. Displayed in menu as "Name (ProvidorName)"
  63. /// </summary>
  64. string Name { get; }
  65. /// <summary>
  66. /// Name of provider for DataSource. Displayed in menu as "Name (ProvidorName)"
  67. /// </summary>
  68. string ProviderName { get; }
  69. /// <summary>
  70. /// Array of paths in bundle.
  71. /// </summary>
  72. string[] GetAssetPathsFromAssetBundle (string assetBundleName);
  73. /// <summary>
  74. /// Name of bundle explicitly associated with asset at path.
  75. /// </summary>
  76. string GetAssetBundleName(string assetPath);
  77. /// <summary>
  78. /// Name of bundle associated with asset at path.
  79. /// The difference between this and GetAssetBundleName() is for assets unassigned to a bundle, but
  80. /// residing inside a folder that is assigned to a bundle. Those assets will implicilty associate
  81. /// with the bundle associated with the parent folder.
  82. /// </summary>
  83. string GetImplicitAssetBundleName(string assetPath);
  84. /// <summary>
  85. /// Array of asset bundle names in project
  86. /// </summary>
  87. string[] GetAllAssetBundleNames();
  88. /// <summary>
  89. /// If this data source is read only.
  90. /// If this returns true, much of the Browsers's interface will be diabled (drag&drop, etc.)
  91. /// </summary>
  92. bool IsReadOnly();
  93. /// <summary>
  94. /// Sets the asset bundle name (and variant) on a given asset
  95. /// </summary>
  96. void SetAssetBundleNameAndVariant (string assetPath, string bundleName, string variantName);
  97. /// <summary>
  98. /// Clears out any asset bundle names that do not have assets associated with them.
  99. /// </summary>
  100. void RemoveUnusedAssetBundleNames();
  101. /// <summary>
  102. /// Signals if this data source can have build target set by tool
  103. /// </summary>
  104. bool CanSpecifyBuildTarget { get; }
  105. /// <summary>
  106. /// Signals if this data source can have output directory set by tool
  107. /// </summary>
  108. bool CanSpecifyBuildOutputDirectory { get; }
  109. /// <summary>
  110. /// Signals if this data source can have build options set by tool
  111. /// </summary>
  112. bool CanSpecifyBuildOptions { get; }
  113. /// <summary>
  114. /// Executes data source's implementation of asset bundle building.
  115. /// Called by "build" button in build tab of tool.
  116. /// </summary>
  117. bool BuildAssetBundles (ABBuildInfo info);
  118. }
  119. }