update operation logic

This commit is contained in:
何冠峰
2024-07-07 16:01:55 +08:00
parent 25231ecd32
commit 260867b588
46 changed files with 525 additions and 678 deletions
@@ -1,4 +1,6 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
{
@@ -29,27 +31,32 @@ namespace YooAsset
if (_steps == ESteps.UnloadUnused)
{
var loaderList = _resManager._loaderList;
var loaderDic = _resManager._loaderDic;
var removeList = new List<LoadBundleFileOperation>(loaderDic.Count);
for (int i = loaderList.Count - 1; i >= 0; i--)
// 注意:优先销毁资源提供者
foreach (var loader in loaderDic.Values)
{
BundleFileLoader loader = loaderList[i];
loader.TryDestroyProviders();
}
for (int i = loaderList.Count - 1; i >= 0; i--)
// 获取销毁列表
foreach (var loader in loaderDic.Values)
{
BundleFileLoader loader = loaderList[i];
if (loader.CanDestroy())
if (loader.CanDestroyLoader())
{
string bundleName = loader.MainBundleInfo.Bundle.BundleName;
loader.Destroy();
loaderList.RemoveAt(i);
loaderDic.Remove(bundleName);
removeList.Add(loader);
}
}
// 销毁文件加载器
foreach (var loader in removeList)
{
string bundleName = loader.BundleFileInfo.Bundle.BundleName;
loader.DestroyLoader();
_resManager._loaderDic.Remove(bundleName);
}
// 注意:调用底层接口释放所有资源
Resources.UnloadUnusedAssets();
@@ -57,10 +64,16 @@ namespace YooAsset
Status = EOperationStatus.Succeed;
}
}
public override void WaitForAsyncComplete()
internal override void InternalWaitForAsyncComplete()
{
InternalOnUpdate();
DebugCheckWaitForAsyncComplete();
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}