parent
5197d42807
commit
ac88fd5cf6
|
@ -23,6 +23,18 @@ namespace YooAsset
|
|||
return _assetInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载报告
|
||||
/// </summary>
|
||||
public DownloadReport GetDownloadReport()
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
{
|
||||
return DownloadReport.CreateDefaultReport();
|
||||
}
|
||||
return Provider.GetDownloadReport();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前状态
|
||||
/// </summary>
|
||||
|
@ -63,7 +75,7 @@ namespace YooAsset
|
|||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return 0;
|
||||
return Provider.Progress;
|
||||
return Provider.GetLoadProgress();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -307,5 +307,36 @@ namespace YooAsset
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载报告
|
||||
/// </summary>
|
||||
public override DownloadReport GetDownloadReport()
|
||||
{
|
||||
if (_downloader != null)
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = _downloader.DownloadProgress;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = (long)_downloader.DownloadedBytes;
|
||||
return report;
|
||||
}
|
||||
else if(_unpacker != null)
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = _unpacker.DownloadProgress;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = (long)_unpacker.DownloadedBytes;
|
||||
return report;
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = 1f;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = MainBundleInfo.Bundle.FileSize;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -226,5 +226,36 @@ namespace YooAsset
|
|||
YooLogger.Error($"WebGL platform not support {nameof(WaitForAsyncComplete)} ! Use the async load method instead of the sync load method !");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载报告
|
||||
/// </summary>
|
||||
public override DownloadReport GetDownloadReport()
|
||||
{
|
||||
if (_downloader != null)
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = _downloader.DownloadProgress;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = (long)_downloader.DownloadedBytes;
|
||||
return report;
|
||||
}
|
||||
else if (_webRequest != null)
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = _webRequest.downloadProgress;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||
return report;
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = 1f;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = MainBundleInfo.Bundle.FileSize;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -82,34 +82,6 @@ namespace YooAsset
|
|||
RefCount--;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轮询更新
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
/// <summary>
|
||||
/// 销毁
|
||||
/// </summary>
|
||||
public virtual void Destroy(bool forceDestroy)
|
||||
{
|
||||
IsDestroyed = true;
|
||||
|
||||
// Check fatal
|
||||
if (forceDestroy == false)
|
||||
{
|
||||
if (RefCount > 0)
|
||||
throw new Exception($"Bundle file loader ref is not zero : {MainBundleInfo.Bundle.BundleName}");
|
||||
if (IsDone() == false)
|
||||
throw new Exception($"Bundle file loader is not done : {MainBundleInfo.Bundle.BundleName}");
|
||||
}
|
||||
|
||||
if (CacheBundle != null)
|
||||
{
|
||||
CacheBundle.Unload(true);
|
||||
CacheBundle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否完毕(无论成功或失败)
|
||||
/// </summary>
|
||||
|
@ -159,9 +131,43 @@ namespace YooAsset
|
|||
_providers.Clear();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 轮询更新
|
||||
/// </summary>
|
||||
public abstract void Update();
|
||||
|
||||
/// <summary>
|
||||
/// 销毁
|
||||
/// </summary>
|
||||
public virtual void Destroy(bool forceDestroy)
|
||||
{
|
||||
IsDestroyed = true;
|
||||
|
||||
// Check fatal
|
||||
if (forceDestroy == false)
|
||||
{
|
||||
if (RefCount > 0)
|
||||
throw new Exception($"Bundle file loader ref is not zero : {MainBundleInfo.Bundle.BundleName}");
|
||||
if (IsDone() == false)
|
||||
throw new Exception($"Bundle file loader is not done : {MainBundleInfo.Bundle.BundleName}");
|
||||
}
|
||||
|
||||
if (CacheBundle != null)
|
||||
{
|
||||
CacheBundle.Unload(true);
|
||||
CacheBundle = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主线程等待异步操作完毕
|
||||
/// </summary>
|
||||
public abstract void WaitForAsyncComplete();
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载报告
|
||||
/// </summary>
|
||||
public abstract DownloadReport GetDownloadReport();
|
||||
}
|
||||
}
|
|
@ -9,12 +9,12 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 依赖的资源包加载器列表
|
||||
/// </summary>
|
||||
private readonly List<BundleLoaderBase> _dependBundles;
|
||||
internal readonly List<BundleLoaderBase> DependBundles;
|
||||
|
||||
|
||||
public DependAssetBundleGroup(List<BundleLoaderBase> dpendBundles)
|
||||
{
|
||||
_dependBundles = dpendBundles;
|
||||
DependBundles = dpendBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -22,7 +22,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public bool IsDone()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
if (loader.IsDone() == false)
|
||||
return false;
|
||||
|
@ -35,7 +35,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public bool IsSucceed()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
if (loader.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
|
@ -50,7 +50,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string GetLastError()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
if (loader.Status != BundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
|
@ -65,7 +65,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public void WaitForAsyncComplete()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
if (loader.IsDone() == false)
|
||||
loader.WaitForAsyncComplete();
|
||||
|
@ -77,7 +77,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public void Reference()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
loader.Reference();
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
loader.Release();
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
foreach (var loader in DependBundles)
|
||||
{
|
||||
var bundleInfo = new DebugBundleInfo();
|
||||
bundleInfo.BundleName = loader.MainBundleInfo.Bundle.BundleName;
|
||||
|
|
|
@ -167,5 +167,36 @@ namespace YooAsset
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载报告
|
||||
/// </summary>
|
||||
public override DownloadReport GetDownloadReport()
|
||||
{
|
||||
if (_downloader != null)
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = _downloader.DownloadProgress;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = (long)_downloader.DownloadedBytes;
|
||||
return report;
|
||||
}
|
||||
else if (_unpacker != null)
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = _unpacker.DownloadProgress;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = (long)_unpacker.DownloadedBytes;
|
||||
return report;
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = 1f;
|
||||
report.TotalSize = MainBundleInfo.Bundle.FileSize;
|
||||
report.DownloadedBytes = MainBundleInfo.Bundle.FileSize;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,15 +7,6 @@ namespace YooAsset
|
|||
internal sealed class BundledAssetProvider : BundledProvider
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cacheRequest == null)
|
||||
return 0;
|
||||
return _cacheRequest.progress;
|
||||
}
|
||||
}
|
||||
|
||||
public BundledAssetProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
|
@ -127,5 +118,11 @@ namespace YooAsset
|
|||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
public override float GetLoadProgress()
|
||||
{
|
||||
if (_cacheRequest == null)
|
||||
return 0;
|
||||
return _cacheRequest.progress;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,22 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载报告
|
||||
/// </summary>
|
||||
public override DownloadReport GetDownloadReport()
|
||||
{
|
||||
DownloadReport result = OwnerBundle.GetDownloadReport();
|
||||
foreach (var bundleLoader in DependBundleGroup.DependBundles)
|
||||
{
|
||||
var report = bundleLoader.GetDownloadReport();
|
||||
result.TotalSize += report.TotalSize;
|
||||
result.DownloadedBytes += report.DownloadedBytes;
|
||||
}
|
||||
result.Progress = result.DownloadedBytes / result.TotalSize;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的调试信息列表
|
||||
/// </summary>
|
||||
|
|
|
@ -3,17 +3,6 @@ namespace YooAsset
|
|||
{
|
||||
internal class BundledRawFileProvider : BundledProvider
|
||||
{
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public BundledRawFileProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -13,15 +13,6 @@ namespace YooAsset
|
|||
private readonly bool _activateOnLoad;
|
||||
private readonly int _priority;
|
||||
private AsyncOperation _asyncOp;
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_asyncOp == null)
|
||||
return 0;
|
||||
return _asyncOp.progress;
|
||||
}
|
||||
}
|
||||
|
||||
public BundledSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
|
@ -108,5 +99,11 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
}
|
||||
public override float GetLoadProgress()
|
||||
{
|
||||
if (_asyncOp == null)
|
||||
return 0;
|
||||
return _asyncOp.progress;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,15 +7,6 @@ namespace YooAsset
|
|||
internal sealed class BundledSubAssetsProvider : BundledProvider
|
||||
{
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_cacheRequest == null)
|
||||
return 0;
|
||||
return _cacheRequest.progress;
|
||||
}
|
||||
}
|
||||
|
||||
public BundledSubAssetsProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
|
@ -116,5 +107,11 @@ namespace YooAsset
|
|||
InvokeCompletion();
|
||||
}
|
||||
}
|
||||
public override float GetLoadProgress()
|
||||
{
|
||||
if (_cacheRequest == null)
|
||||
return 0;
|
||||
return _cacheRequest.progress;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,17 +3,6 @@ namespace YooAsset
|
|||
{
|
||||
internal sealed class CompletedProvider : ProviderBase
|
||||
{
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public CompletedProvider(AssetInfo assetInfo) : base(null, string.Empty, assetInfo)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -6,17 +6,6 @@ namespace YooAsset
|
|||
{
|
||||
internal sealed class DatabaseAssetProvider : ProviderBase
|
||||
{
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseAssetProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -3,17 +3,6 @@ namespace YooAsset
|
|||
{
|
||||
internal class DatabaseRawFileProvider : ProviderBase
|
||||
{
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseRawFileProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -9,15 +9,6 @@ namespace YooAsset
|
|||
private readonly bool _activateOnLoad;
|
||||
private readonly int _priority;
|
||||
private AsyncOperation _asyncOp;
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_asyncOp == null)
|
||||
return 0;
|
||||
return _asyncOp.progress;
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseSceneProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool activateOnLoad, int priority) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
|
@ -77,5 +68,11 @@ namespace YooAsset
|
|||
}
|
||||
#endif
|
||||
}
|
||||
public override float GetLoadProgress()
|
||||
{
|
||||
if (_asyncOp == null)
|
||||
return 0;
|
||||
return _asyncOp.progress;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,17 +6,6 @@ namespace YooAsset
|
|||
{
|
||||
internal sealed class DatabaseSubAssetsProvider : ProviderBase
|
||||
{
|
||||
public override float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsDone)
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public DatabaseSubAssetsProvider(AssetSystemImpl impl, string providerGUID, AssetInfo assetInfo) : base(impl, providerGUID, assetInfo)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -84,17 +84,6 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载进度
|
||||
/// </summary>
|
||||
public virtual float Progress
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
||||
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
|
||||
|
@ -120,6 +109,25 @@ namespace YooAsset
|
|||
IsDestroyed = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取加载进度
|
||||
/// </summary>
|
||||
public virtual float GetLoadProgress()
|
||||
{
|
||||
if (IsDone)
|
||||
return 1f;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下载进度
|
||||
/// </summary>
|
||||
public virtual DownloadReport GetDownloadReport()
|
||||
{
|
||||
return DownloadReport.CreateDefaultReport();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否可以销毁
|
||||
/// </summary>
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
public struct DownloadReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 下载进度(0f~1f)
|
||||
/// </summary>
|
||||
public float Progress;
|
||||
|
||||
/// <summary>
|
||||
/// 需要下载的总字节数
|
||||
/// </summary>
|
||||
public long TotalSize;
|
||||
|
||||
/// <summary>
|
||||
/// 已经下载的字节数
|
||||
/// </summary>
|
||||
public long DownloadedBytes;
|
||||
|
||||
public static DownloadReport CreateDefaultReport()
|
||||
{
|
||||
DownloadReport report = new DownloadReport();
|
||||
report.Progress = 1f;
|
||||
report.TotalSize = 0;
|
||||
report.DownloadedBytes = 0;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d40b8341fcd4ad2478eb1a890ebf0476
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -30,7 +30,7 @@ namespace YooAsset
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度
|
||||
/// 下载进度(0f~1f)
|
||||
/// </summary>
|
||||
public float DownloadProgress
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue