AssetCreator.cs 886 B

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. namespace XGame.Framework.Asset
  3. {
  4. internal static class AssetCreator
  5. {
  6. internal static Asset Create(string addressableName, object obj)
  7. {
  8. if (obj == null)
  9. {
  10. AssetsLog.Warn($"Asset create error: object is null. Path:{addressableName}");
  11. return null;
  12. }
  13. Asset asset;
  14. if (obj is AssetBundle)
  15. {
  16. asset = new BundleAsset();
  17. }
  18. else if (obj is Object)
  19. {
  20. asset = new ObjectAsset();
  21. Monitor.AssetsMonitor.RecordAsset(addressableName, obj);
  22. }
  23. else
  24. {
  25. asset = new BinaryAsset();
  26. }
  27. asset.Init(addressableName);
  28. asset.Source = obj;
  29. return asset;
  30. }
  31. }
  32. }