mirror of https://github.com/tuyoogame/YooAsset
Update AssetSystem
parent
39c69b1d98
commit
68430488b3
|
@ -8,7 +8,7 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
internal static class AssetSystem
|
internal static class AssetSystem
|
||||||
{
|
{
|
||||||
private static readonly List<BundleFileLoader> _loaders = new List<BundleFileLoader>(1000);
|
private static readonly List<AssetBundleLoader> _loaders = new List<AssetBundleLoader>(1000);
|
||||||
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
private static readonly List<ProviderBase> _providers = new List<ProviderBase>(1000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -90,12 +90,12 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
for (int i = _loaders.Count - 1; i >= 0; i--)
|
for (int i = _loaders.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
BundleFileLoader loader = _loaders[i];
|
AssetBundleLoader loader = _loaders[i];
|
||||||
loader.TryDestroyAllProviders();
|
loader.TryDestroyAllProviders();
|
||||||
}
|
}
|
||||||
for (int i = _loaders.Count - 1; i >= 0; i--)
|
for (int i = _loaders.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
BundleFileLoader loader = _loaders[i];
|
AssetBundleLoader loader = _loaders[i];
|
||||||
if (loader.CanDestroy())
|
if (loader.CanDestroy())
|
||||||
{
|
{
|
||||||
loader.Destroy(false);
|
loader.Destroy(false);
|
||||||
|
@ -179,22 +179,22 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static BundleFileLoader CreateOwnerBundleLoader(string assetPath)
|
internal static AssetBundleLoader CreateOwnerAssetBundleLoader(string assetPath)
|
||||||
{
|
{
|
||||||
string bundleName = BundleServices.GetBundleName(assetPath);
|
string bundleName = BundleServices.GetBundleName(assetPath);
|
||||||
BundleInfo bundleInfo = BundleServices.GetBundleInfo(bundleName);
|
BundleInfo bundleInfo = BundleServices.GetBundleInfo(bundleName);
|
||||||
return CreateBundleFileLoaderInternal(bundleInfo);
|
return CreateAssetBundleLoaderInternal(bundleInfo);
|
||||||
}
|
}
|
||||||
internal static List<BundleFileLoader> CreateDependBundleLoaders(string assetPath)
|
internal static List<AssetBundleLoader> CreateDependAssetBundleLoaders(string assetPath)
|
||||||
{
|
{
|
||||||
List<BundleFileLoader> result = new List<BundleFileLoader>();
|
List<AssetBundleLoader> result = new List<AssetBundleLoader>();
|
||||||
string[] depends = BundleServices.GetAllDependencies(assetPath);
|
string[] depends = BundleServices.GetAllDependencies(assetPath);
|
||||||
if (depends != null)
|
if (depends != null)
|
||||||
{
|
{
|
||||||
foreach (var dependBundleName in depends)
|
foreach (var dependBundleName in depends)
|
||||||
{
|
{
|
||||||
BundleInfo dependBundleInfo = BundleServices.GetBundleInfo(dependBundleName);
|
BundleInfo dependBundleInfo = BundleServices.GetBundleInfo(dependBundleName);
|
||||||
BundleFileLoader dependLoader = CreateBundleFileLoaderInternal(dependBundleInfo);
|
AssetBundleLoader dependLoader = CreateAssetBundleLoaderInternal(dependBundleInfo);
|
||||||
result.Add(dependLoader);
|
result.Add(dependLoader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,24 +208,24 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BundleFileLoader CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
private static AssetBundleLoader CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
// 如果加载器已经存在
|
// 如果加载器已经存在
|
||||||
BundleFileLoader loader = TryGetBundleFileLoader(bundleInfo.BundleName);
|
AssetBundleLoader loader = TryGetAssetBundleLoader(bundleInfo.BundleName);
|
||||||
if (loader != null)
|
if (loader != null)
|
||||||
return loader;
|
return loader;
|
||||||
|
|
||||||
// 新增下载需求
|
// 新增下载需求
|
||||||
loader = new BundleFileLoader(bundleInfo);
|
loader = new AssetBundleLoader(bundleInfo);
|
||||||
_loaders.Add(loader);
|
_loaders.Add(loader);
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
private static BundleFileLoader TryGetBundleFileLoader(string bundleName)
|
private static AssetBundleLoader TryGetAssetBundleLoader(string bundleName)
|
||||||
{
|
{
|
||||||
BundleFileLoader loader = null;
|
AssetBundleLoader loader = null;
|
||||||
for (int i = 0; i < _loaders.Count; i++)
|
for (int i = 0; i < _loaders.Count; i++)
|
||||||
{
|
{
|
||||||
BundleFileLoader temp = _loaders[i];
|
AssetBundleLoader temp = _loaders[i];
|
||||||
if (temp.BundleFileInfo.BundleName.Equals(bundleName))
|
if (temp.BundleFileInfo.BundleName.Equals(bundleName))
|
||||||
{
|
{
|
||||||
loader = temp;
|
loader = temp;
|
||||||
|
|
|
@ -5,7 +5,7 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class BundleFileLoader
|
internal class AssetBundleLoader
|
||||||
{
|
{
|
||||||
public enum EStatus
|
public enum EStatus
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ namespace YooAsset
|
||||||
internal AssetBundle CacheBundle { private set; get; }
|
internal AssetBundle CacheBundle { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public BundleFileLoader(BundleInfo bundleInfo)
|
public AssetBundleLoader(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
BundleFileInfo = bundleInfo;
|
BundleFileInfo = bundleInfo;
|
||||||
RefCount = 0;
|
RefCount = 0;
|
||||||
|
@ -157,7 +157,7 @@ namespace YooAsset
|
||||||
if (BundleFileInfo.IsEncrypted)
|
if (BundleFileInfo.IsEncrypted)
|
||||||
{
|
{
|
||||||
if (AssetSystem.DecryptionServices == null)
|
if (AssetSystem.DecryptionServices == null)
|
||||||
throw new Exception($"{nameof(BundleFileLoader)} need IDecryptServices : {BundleFileInfo.BundleName}");
|
throw new Exception($"{nameof(AssetBundleLoader)} need IDecryptServices : {BundleFileInfo.BundleName}");
|
||||||
|
|
||||||
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo);
|
ulong offset = AssetSystem.DecryptionServices.GetFileOffset(BundleFileInfo);
|
||||||
if (_isWaitForAsyncComplete)
|
if (_isWaitForAsyncComplete)
|
|
@ -4,16 +4,16 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DependBundleGrouper
|
internal class DependAssetBundleGrouper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包加载器列表
|
/// 依赖的资源包加载器列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<BundleFileLoader> _dependBundles;
|
private readonly List<AssetBundleLoader> _dependBundles;
|
||||||
|
|
||||||
public DependBundleGrouper(string assetPath)
|
public DependAssetBundleGrouper(string assetPath)
|
||||||
{
|
{
|
||||||
_dependBundles = AssetSystem.CreateDependBundleLoaders(assetPath);
|
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
|
@ -5,15 +5,15 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
internal abstract class BundledProvider : ProviderBase
|
internal abstract class BundledProvider : ProviderBase
|
||||||
{
|
{
|
||||||
protected BundleFileLoader OwnerBundle { private set; get; }
|
protected AssetBundleLoader OwnerBundle { private set; get; }
|
||||||
protected DependBundleGrouper DependBundles { private set; get; }
|
protected DependAssetBundleGrouper DependBundles { private set; get; }
|
||||||
|
|
||||||
public BundledProvider(string assetPath, System.Type assetType) : base(assetPath, assetType)
|
public BundledProvider(string assetPath, System.Type assetType) : base(assetPath, assetType)
|
||||||
{
|
{
|
||||||
OwnerBundle = AssetSystem.CreateOwnerBundleLoader(assetPath);
|
OwnerBundle = AssetSystem.CreateOwnerAssetBundleLoader(assetPath);
|
||||||
OwnerBundle.Reference();
|
OwnerBundle.Reference();
|
||||||
OwnerBundle.AddProvider(this);
|
OwnerBundle.AddProvider(this);
|
||||||
DependBundles = new DependBundleGrouper(assetPath);
|
DependBundles = new DependAssetBundleGrouper(assetPath);
|
||||||
DependBundles.Reference();
|
DependBundles.Reference();
|
||||||
}
|
}
|
||||||
public override void Destory()
|
public override void Destory()
|
||||||
|
|
Loading…
Reference in New Issue