mirror of https://github.com/tuyoogame/YooAsset
update asset system
parent
f24ae6eb2a
commit
561cf411ef
|
@ -4,17 +4,17 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class DependAssetBundleGroup
|
internal class DependAssetBundles
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖的资源包加载器列表
|
/// 依赖的资源包加载器列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal readonly List<BundleLoaderBase> DependBundles;
|
internal readonly List<BundleLoaderBase> DependList;
|
||||||
|
|
||||||
|
|
||||||
public DependAssetBundleGroup(List<BundleLoaderBase> dpendBundles)
|
public DependAssetBundles(List<BundleLoaderBase> dpendList)
|
||||||
{
|
{
|
||||||
DependBundles = dpendBundles;
|
DependList = dpendList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -22,7 +22,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsDone()
|
public bool IsDone()
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
if (loader.IsDone() == false)
|
if (loader.IsDone() == false)
|
||||||
return false;
|
return false;
|
||||||
|
@ -35,7 +35,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsSucceed()
|
public bool IsSucceed()
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
if (loader.Status != BundleLoaderBase.EStatus.Succeed)
|
if (loader.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
|
@ -50,7 +50,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetLastError()
|
public string GetLastError()
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
if (loader.Status != BundleLoaderBase.EStatus.Succeed)
|
if (loader.Status != BundleLoaderBase.EStatus.Succeed)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void WaitForAsyncComplete()
|
public void WaitForAsyncComplete()
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
if (loader.IsDone() == false)
|
if (loader.IsDone() == false)
|
||||||
loader.WaitForAsyncComplete();
|
loader.WaitForAsyncComplete();
|
||||||
|
@ -77,7 +77,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Reference()
|
public void Reference()
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
loader.Reference();
|
loader.Reference();
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Release()
|
public void Release()
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
loader.Release();
|
loader.Release();
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
|
internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
|
||||||
{
|
{
|
||||||
foreach (var loader in DependBundles)
|
foreach (var loader in DependList)
|
||||||
{
|
{
|
||||||
var bundleInfo = new DebugBundleInfo();
|
var bundleInfo = new DebugBundleInfo();
|
||||||
bundleInfo.BundleName = loader.MainBundleInfo.Bundle.BundleName;
|
bundleInfo.BundleName = loader.MainBundleInfo.Bundle.BundleName;
|
|
@ -28,19 +28,19 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
DependBundleGroup.WaitForAsyncComplete();
|
DependBundles.WaitForAsyncComplete();
|
||||||
OwnerBundle.WaitForAsyncComplete();
|
OwnerBundle.WaitForAsyncComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DependBundleGroup.IsDone() == false)
|
if (DependBundles.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (DependBundleGroup.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
LastError = DependBundleGroup.GetLastError();
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,19 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
DependBundleGroup.WaitForAsyncComplete();
|
DependBundles.WaitForAsyncComplete();
|
||||||
OwnerBundle.WaitForAsyncComplete();
|
OwnerBundle.WaitForAsyncComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DependBundleGroup.IsDone() == false)
|
if (DependBundles.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (DependBundleGroup.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
LastError = DependBundleGroup.GetLastError();
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,15 +36,15 @@ namespace YooAsset
|
||||||
// 1. 检测资源包
|
// 1. 检测资源包
|
||||||
if (Status == EStatus.CheckBundle)
|
if (Status == EStatus.CheckBundle)
|
||||||
{
|
{
|
||||||
if (DependBundleGroup.IsDone() == false)
|
if (DependBundles.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (DependBundleGroup.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
LastError = DependBundleGroup.GetLastError();
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,19 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
if (IsWaitForAsyncComplete)
|
if (IsWaitForAsyncComplete)
|
||||||
{
|
{
|
||||||
DependBundleGroup.WaitForAsyncComplete();
|
DependBundles.WaitForAsyncComplete();
|
||||||
OwnerBundle.WaitForAsyncComplete();
|
OwnerBundle.WaitForAsyncComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DependBundleGroup.IsDone() == false)
|
if (DependBundles.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
if (OwnerBundle.IsDone() == false)
|
if (OwnerBundle.IsDone() == false)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (DependBundleGroup.IsSucceed() == false)
|
if (DependBundles.IsSucceed() == false)
|
||||||
{
|
{
|
||||||
Status = EStatus.Failed;
|
Status = EStatus.Failed;
|
||||||
LastError = DependBundleGroup.GetLastError();
|
LastError = DependBundles.GetLastError();
|
||||||
InvokeCompletion();
|
InvokeCompletion();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace YooAsset
|
||||||
|
|
||||||
|
|
||||||
protected BundleLoaderBase OwnerBundle { private set; get; }
|
protected BundleLoaderBase OwnerBundle { private set; get; }
|
||||||
protected DependAssetBundleGroup DependBundleGroup { private set; get; }
|
protected DependAssetBundles DependBundles { private set; get; }
|
||||||
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
||||||
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
|
private readonly List<OperationHandleBase> _handles = new List<OperationHandleBase>();
|
||||||
|
|
||||||
|
@ -109,9 +109,9 @@ namespace YooAsset
|
||||||
OwnerBundle.Reference();
|
OwnerBundle.Reference();
|
||||||
OwnerBundle.AddProvider(this);
|
OwnerBundle.AddProvider(this);
|
||||||
|
|
||||||
var dependBundles = impl.CreateDependAssetBundleLoaders(assetInfo);
|
var dependList = impl.CreateDependAssetBundleLoaders(assetInfo);
|
||||||
DependBundleGroup = new DependAssetBundleGroup(dependBundles);
|
DependBundles = new DependAssetBundles(dependList);
|
||||||
DependBundleGroup.Reference();
|
DependBundles.Reference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,10 +133,10 @@ namespace YooAsset
|
||||||
OwnerBundle.Release();
|
OwnerBundle.Release();
|
||||||
OwnerBundle = null;
|
OwnerBundle = null;
|
||||||
}
|
}
|
||||||
if (DependBundleGroup != null)
|
if (DependBundles != null)
|
||||||
{
|
{
|
||||||
DependBundleGroup.Release();
|
DependBundles.Release();
|
||||||
DependBundleGroup = null;
|
DependBundles = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ namespace YooAsset
|
||||||
DownloadReport result = new DownloadReport();
|
DownloadReport result = new DownloadReport();
|
||||||
result.TotalSize = (ulong)OwnerBundle.MainBundleInfo.Bundle.FileSize;
|
result.TotalSize = (ulong)OwnerBundle.MainBundleInfo.Bundle.FileSize;
|
||||||
result.DownloadedBytes = OwnerBundle.DownloadedBytes;
|
result.DownloadedBytes = OwnerBundle.DownloadedBytes;
|
||||||
foreach (var dependBundle in DependBundleGroup.DependBundles)
|
foreach (var dependBundle in DependBundles.DependList)
|
||||||
{
|
{
|
||||||
result.TotalSize += (ulong)dependBundle.MainBundleInfo.Bundle.FileSize;
|
result.TotalSize += (ulong)dependBundle.MainBundleInfo.Bundle.FileSize;
|
||||||
result.DownloadedBytes += dependBundle.DownloadedBytes;
|
result.DownloadedBytes += dependBundle.DownloadedBytes;
|
||||||
|
@ -342,7 +342,7 @@ namespace YooAsset
|
||||||
bundleInfo.Status = OwnerBundle.Status.ToString();
|
bundleInfo.Status = OwnerBundle.Status.ToString();
|
||||||
output.Add(bundleInfo);
|
output.Add(bundleInfo);
|
||||||
|
|
||||||
DependBundleGroup.GetBundleDebugInfos(output);
|
DependBundles.GetBundleDebugInfos(output);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue