update runtime code
重构了OperationSystem的机制。从列表模式修改为链模式
This commit is contained in:
@@ -162,7 +162,7 @@ namespace YooAsset
|
||||
_instantiateAsync.Cancel();
|
||||
#endif
|
||||
|
||||
SetAbort();
|
||||
AbortOperation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+5
-9
@@ -67,11 +67,16 @@ namespace YooAsset
|
||||
if (_steps == ESteps.LoadFile)
|
||||
{
|
||||
if (_loadBundleOp == null)
|
||||
{
|
||||
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
||||
_loadBundleOp.StartOperation();
|
||||
AddChildOperation(_loadBundleOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_loadBundleOp.WaitForAsyncComplete();
|
||||
|
||||
_loadBundleOp.UpdateOperation();
|
||||
DownloadProgress = _loadBundleOp.DownloadProgress;
|
||||
DownloadedBytes = _loadBundleOp.DownloadedBytes;
|
||||
if (_loadBundleOp.IsDone == false)
|
||||
@@ -209,14 +214,5 @@ namespace YooAsset
|
||||
_removeList.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 终止下载任务
|
||||
/// </summary>
|
||||
public void AbortDownloadOperation()
|
||||
{
|
||||
if (_loadBundleOp != null)
|
||||
_loadBundleOp.AbortDownloadOperation();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace YooAsset
|
||||
// 注意:终止所有下载任务
|
||||
foreach (var loader in _resManager.LoaderDic.Values)
|
||||
{
|
||||
loader.AbortDownloadOperation();
|
||||
loader.AbortOperation();
|
||||
}
|
||||
_steps = ESteps.CheckLoading;
|
||||
}
|
||||
|
||||
@@ -13,11 +13,14 @@ namespace YooAsset
|
||||
if (_loadAllAssetsOp == null)
|
||||
{
|
||||
_loadAllAssetsOp = BundleResultObject.LoadAllAssetsAsync(MainAssetInfo);
|
||||
_loadAllAssetsOp.StartOperation();
|
||||
AddChildOperation(_loadAllAssetsOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_loadAllAssetsOp.WaitForAsyncComplete();
|
||||
|
||||
_loadAllAssetsOp.UpdateOperation();
|
||||
Progress = _loadAllAssetsOp.Progress;
|
||||
if (_loadAllAssetsOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -13,11 +13,14 @@ namespace YooAsset
|
||||
if (_loadAssetOp == null)
|
||||
{
|
||||
_loadAssetOp = BundleResultObject.LoadAssetAsync(MainAssetInfo);
|
||||
_loadAssetOp.StartOperation();
|
||||
AddChildOperation(_loadAssetOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_loadAssetOp.WaitForAsyncComplete();
|
||||
|
||||
_loadAssetOp.UpdateOperation();
|
||||
Progress = _loadAssetOp.Progress;
|
||||
if (_loadAssetOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -10,7 +10,8 @@ namespace YooAsset
|
||||
protected enum ESteps
|
||||
{
|
||||
None = 0,
|
||||
LoadBundleFile,
|
||||
StartBundleLoader,
|
||||
WaitBundleLoader,
|
||||
ProcessBundleResult,
|
||||
Done,
|
||||
}
|
||||
@@ -99,14 +100,24 @@ namespace YooAsset
|
||||
internal override void InternalStart()
|
||||
{
|
||||
DebugBeginRecording();
|
||||
_steps = ESteps.LoadBundleFile;
|
||||
_steps = ESteps.StartBundleLoader;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadBundleFile)
|
||||
if (_steps == ESteps.StartBundleLoader)
|
||||
{
|
||||
foreach (var bundleLoader in _bundleLoaders)
|
||||
{
|
||||
bundleLoader.StartOperation();
|
||||
AddChildOperation(bundleLoader);
|
||||
}
|
||||
_steps = ESteps.WaitBundleLoader;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.WaitBundleLoader)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
@@ -116,6 +127,13 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
// 更新资源包加载器
|
||||
foreach (var bundleLoader in _bundleLoaders)
|
||||
{
|
||||
bundleLoader.UpdateOperation();
|
||||
}
|
||||
|
||||
// 检测加载是否完成
|
||||
foreach (var bundleLoader in _bundleLoaders)
|
||||
{
|
||||
if (bundleLoader.IsDone == false)
|
||||
@@ -128,6 +146,7 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
// 检测加载结果
|
||||
BundleResultObject = _mainBundleLoader.Result;
|
||||
if (BundleResultObject == null)
|
||||
{
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace YooAsset
|
||||
if (_loadSceneOp == null)
|
||||
{
|
||||
_loadSceneOp = BundleResultObject.LoadSceneOperation(MainAssetInfo, _loadParams, _suspendLoad);
|
||||
_loadSceneOp.StartOperation();
|
||||
AddChildOperation(_loadSceneOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
@@ -32,6 +34,7 @@ namespace YooAsset
|
||||
if (_suspendLoad == false)
|
||||
_loadSceneOp.UnSuspendLoad();
|
||||
|
||||
_loadSceneOp.UpdateOperation();
|
||||
Progress = _loadSceneOp.Progress;
|
||||
if (_loadSceneOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -13,11 +13,14 @@ namespace YooAsset
|
||||
if (_loadSubAssetsOp == null)
|
||||
{
|
||||
_loadSubAssetsOp = BundleResultObject.LoadSubAssetsAsync(MainAssetInfo);
|
||||
_loadSubAssetsOp.StartOperation();
|
||||
AddChildOperation(_loadSubAssetsOp);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_loadSubAssetsOp.WaitForAsyncComplete();
|
||||
|
||||
_loadSubAssetsOp.UpdateOperation();
|
||||
Progress = _loadSubAssetsOp.Progress;
|
||||
if (_loadSubAssetsOp.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -321,7 +321,6 @@ namespace YooAsset
|
||||
|
||||
// 新增下载需求
|
||||
loaderOperation = new LoadBundleFileOperation(this, bundleInfo);
|
||||
OperationSystem.StartOperation(PackageName, loaderOperation);
|
||||
LoaderDic.Add(bundleName, loaderOperation);
|
||||
return loaderOperation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user