update asset system

This commit is contained in:
hevinci
2022-12-05 16:29:45 +08:00
parent ac88fd5cf6
commit 824d1c1501
12 changed files with 48 additions and 142 deletions
@@ -90,6 +90,7 @@ namespace YooAsset
// 3. 检测加载结果
if (Status == EStatus.Checking)
{
Progress = _cacheRequest.progress;
if (_cacheRequest != null)
{
if (IsWaitForAsyncComplete)
@@ -118,11 +119,5 @@ namespace YooAsset
InvokeCompletion();
}
}
public override float GetLoadProgress()
{
if (_cacheRequest == null)
return 0;
return _cacheRequest.progress;
}
}
}
@@ -40,12 +40,13 @@ namespace YooAsset
/// </summary>
public override DownloadReport GetDownloadReport()
{
DownloadReport result = OwnerBundle.GetDownloadReport();
foreach (var bundleLoader in DependBundleGroup.DependBundles)
DownloadReport result = new DownloadReport();
result.TotalSize = (ulong)OwnerBundle.MainBundleInfo.Bundle.FileSize;
result.DownloadedBytes = OwnerBundle.DownloadedBytes;
foreach (var dependBundle in DependBundleGroup.DependBundles)
{
var report = bundleLoader.GetDownloadReport();
result.TotalSize += report.TotalSize;
result.DownloadedBytes += report.DownloadedBytes;
result.TotalSize += (ulong)dependBundle.MainBundleInfo.Bundle.FileSize;
result.DownloadedBytes += dependBundle.DownloadedBytes;
}
result.Progress = result.DownloadedBytes / result.TotalSize;
return result;
@@ -84,6 +84,7 @@ namespace YooAsset
// 3. 检测加载结果
if (Status == EStatus.Checking)
{
Progress = _asyncOp.progress;
if (_asyncOp.isDone)
{
if (SceneObject.IsValid() && _activateOnLoad)
@@ -99,11 +100,5 @@ namespace YooAsset
}
}
}
public override float GetLoadProgress()
{
if (_asyncOp == null)
return 0;
return _asyncOp.progress;
}
}
}
@@ -79,6 +79,7 @@ namespace YooAsset
// 3. 检测加载结果
if (Status == EStatus.Checking)
{
Progress = _cacheRequest.progress;
if (_cacheRequest != null)
{
if (IsWaitForAsyncComplete)
@@ -107,11 +108,5 @@ namespace YooAsset
InvokeCompletion();
}
}
public override float GetLoadProgress()
{
if (_cacheRequest == null)
return 0;
return _cacheRequest.progress;
}
}
}
@@ -52,6 +52,7 @@ namespace YooAsset
// 2. 检测加载结果
if (Status == EStatus.Checking)
{
Progress = _asyncOp.progress;
if (_asyncOp.isDone)
{
if (SceneObject.IsValid() && _activateOnLoad)
@@ -68,11 +69,5 @@ namespace YooAsset
}
#endif
}
public override float GetLoadProgress()
{
if (_asyncOp == null)
return 0;
return _asyncOp.progress;
}
}
}
@@ -63,6 +63,11 @@ namespace YooAsset
/// </summary>
public string LastError { protected set; get; } = string.Empty;
/// <summary>
/// 加载进度
/// </summary>
public float Progress { protected set; get; } = 0f;
/// <summary>
/// 引用计数
/// </summary>
@@ -109,17 +114,6 @@ namespace YooAsset
IsDestroyed = true;
}
/// <summary>
/// 获取加载进度
/// </summary>
public virtual float GetLoadProgress()
{
if (IsDone)
return 1f;
else
return 0;
}
/// <summary>
/// 获取下载进度
/// </summary>
@@ -227,6 +221,9 @@ namespace YooAsset
private TaskCompletionSource<object> _taskCompletionSource;
protected void InvokeCompletion()
{
// 进度百分百完成
Progress = 1f;
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
List<OperationHandleBase> tempers = new List<OperationHandleBase>(_handles);
foreach (var hande in tempers)