AssetBundleRecord.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using UnityEngine;
  2. namespace AssetBundleBrowser
  3. {
  4. /// <summary>
  5. /// This class maintains a record of a loaded asset bundle, allowing us
  6. /// to associate the full path of an asset bundle with the actual bundle,
  7. /// so that we can:
  8. ///
  9. /// 1. distinguish between bundle variants, which, when loaded
  10. /// resolve to the same name.
  11. ///
  12. /// 2. Differentiate between the same asset bundles built for different platforms.
  13. ///
  14. /// ex:
  15. ///
  16. /// Two asset bundle variants:
  17. ///
  18. /// - variant one: mycylinder.one
  19. /// - variant two: mycylinder.two
  20. ///
  21. /// Will Resolve to "mycylinder" when loaded.
  22. ///
  23. /// Likewise,
  24. ///
  25. /// - iOS: AssetBundles/iOS/myBundle
  26. /// - Android: AssetBundle/Android/myBundle
  27. ///
  28. /// Will both resolve to "mybundle" when loaded.
  29. ///
  30. /// </summary>
  31. internal class AssetBundleRecord
  32. {
  33. /// <summary>
  34. /// Full path of the asset bundle.
  35. /// </summary>
  36. internal string path { get; private set; }
  37. /// <summary>
  38. /// Reference to the loaded asset bundle associated with the path.
  39. /// </summary>
  40. internal AssetBundle bundle { get; private set; }
  41. internal AssetBundleRecord(string path, AssetBundle bundle)
  42. {
  43. if (string.IsNullOrEmpty(path) ||
  44. null == bundle)
  45. {
  46. string msg = string.Format("AssetBundleRecord encountered invalid parameters path={0}, bundle={1}",
  47. path,
  48. bundle);
  49. throw new System.ArgumentException(msg);
  50. }
  51. this.path = path;
  52. this.bundle = bundle;
  53. }
  54. }
  55. }