update asset sytem
资源句柄类增加GetDownloadReport()方法。
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ namespace YooAsset
|
||||
/// 所属资源系统
|
||||
/// </summary>
|
||||
public AssetSystemImpl Impl { private set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 资源包文件信息
|
||||
/// </summary>
|
||||
@@ -47,7 +47,7 @@ namespace YooAsset
|
||||
private readonly List<ProviderBase> _providers = new List<ProviderBase>(100);
|
||||
internal AssetBundle CacheBundle { set; get; }
|
||||
internal string FileLoadPath { set; get; }
|
||||
|
||||
|
||||
|
||||
public BundleLoaderBase(AssetSystemImpl impl, BundleInfo bundleInfo)
|
||||
{
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user