update operation logic
This commit is contained in:
+10
-14
@@ -84,19 +84,17 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
_isWaitForAsyncComplete = true;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
@@ -170,17 +168,15 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
|
||||
+40
-28
@@ -94,8 +94,6 @@ namespace YooAsset
|
||||
// 等待验证完成
|
||||
if (_steps == ESteps.CheckVerifyTempFile)
|
||||
{
|
||||
// 注意:同步解压文件更新
|
||||
_verifyOperation.InternalOnUpdate();
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
||||
@@ -103,21 +101,21 @@ namespace YooAsset
|
||||
{
|
||||
if (_fileSystem.WriteCacheFile(Bundle, _tempFilePath))
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = $"{_fileSystem.GetType().FullName} failed to write file !";
|
||||
Status = EOperationStatus.Failed;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{_fileSystem.GetType().FullName} failed to write file !";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = _verifyOperation.Error;
|
||||
_steps = ESteps.TryAgain;
|
||||
Error = _verifyOperation.Error;
|
||||
}
|
||||
|
||||
// 注意:验证完成后直接删除文件
|
||||
@@ -150,23 +148,30 @@ namespace YooAsset
|
||||
_steps = ESteps.Done;
|
||||
DisposeWebRequest();
|
||||
}
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
bool isReuqestLocalFile = IsRequestLocalFile();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 文件验证
|
||||
if (_verifyOperation != null)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
|
||||
// 注意:如果是导入或解压本地文件,执行等待完毕
|
||||
if (isReuqestLocalFile)
|
||||
{
|
||||
if (_verifyOperation.IsDone == false)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
InternalOnUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,23 +358,30 @@ namespace YooAsset
|
||||
_steps = ESteps.Done;
|
||||
DisposeWebRequest();
|
||||
}
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
bool isReuqestLocalFile = IsRequestLocalFile();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 文件验证
|
||||
if (_verifyOperation != null)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
|
||||
// 注意:如果是导入或解压本地文件,执行等待完毕
|
||||
if (isReuqestLocalFile)
|
||||
{
|
||||
if (_verifyOperation.IsDone == false)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
InternalOnUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-34
@@ -159,31 +159,23 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
_isWaitForAsyncComplete = true;
|
||||
|
||||
int frame = 1000;
|
||||
while (true)
|
||||
{
|
||||
// 保险机制
|
||||
// 注意:如果需要从远端下载资源,可能会触发保险机制!
|
||||
frame--;
|
||||
if (frame == 0)
|
||||
if(_downloadFileOp != null)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(WaitForAsyncComplete)} failed ! Try load bundle {_bundle.BundleName} from remote with sync load method !";
|
||||
if (_downloadFileOp != null && _downloadFileOp.Status == EOperationStatus.Failed)
|
||||
YooLogger.Error($"Try load bundle {_bundle.BundleName} from remote !");
|
||||
|
||||
_steps = ESteps.Done;
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
@@ -299,29 +291,21 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
int frame = 1000;
|
||||
while (true)
|
||||
{
|
||||
// 保险机制
|
||||
// 注意:如果需要从远端下载资源,可能会触发保险机制!
|
||||
frame--;
|
||||
if (frame == 0)
|
||||
if (_downloadFileOp != null)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(WaitForAsyncComplete)} failed ! Try load bundle {_bundle.BundleName} from remote with sync load method !";
|
||||
if (_downloadFileOp != null && _downloadFileOp.Status == EOperationStatus.Failed)
|
||||
YooLogger.Error($"Try load bundle {_bundle.BundleName} from remote !");
|
||||
|
||||
_steps = ESteps.Done;
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
|
||||
+2
-4
@@ -85,14 +85,12 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// 驱动流程
|
||||
// 注意:等待子线程验证文件完毕
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-2
@@ -20,8 +20,7 @@ namespace YooAsset
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
|
||||
@@ -17,20 +17,5 @@ namespace YooAsset
|
||||
_saveFileRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveFilesFolderName);
|
||||
_tempFileRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
||||
}
|
||||
public override FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
{
|
||||
if (RawFileBuildPipeline)
|
||||
{
|
||||
var operation = new DUFSLoadRawBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
var operation = new DUFSLoadAssetBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59b123e460757694180175970bf28826
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DUFSLoadAssetBundleOperation : DCFSLoadAssetBundleOperation
|
||||
{
|
||||
public DUFSLoadAssetBundleOperation(DefaultUnpackFileSystem fileSystem, PackageBundle bundle) : base(fileSystem, bundle)
|
||||
{
|
||||
}
|
||||
public override void WaitForAsyncComplete()
|
||||
{
|
||||
_isWaitForAsyncComplete = true;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 文件解压
|
||||
if (_downloadFileOp != null)
|
||||
{
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class DUFSLoadRawBundleOperation : DCFSLoadRawBundleOperation
|
||||
{
|
||||
public DUFSLoadRawBundleOperation(DefaultUnpackFileSystem fileSystem, PackageBundle bundle) : base(fileSystem, bundle)
|
||||
{
|
||||
}
|
||||
public override void WaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// 文件解压
|
||||
if (_downloadFileOp != null)
|
||||
{
|
||||
if (_downloadFileOp.IsDone == false)
|
||||
_downloadFileOp.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
// 完成后退出
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47f6fe3a815d28e49815db7c09c1fa76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+2
-3
@@ -62,10 +62,9 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
if (IsDone == false)
|
||||
if (_steps != ESteps.Done)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
|
||||
+15
-1
@@ -89,7 +89,7 @@ namespace YooAsset
|
||||
float offset = UnityEngine.Time.realtimeSinceStartup - _latestDownloadRealtime;
|
||||
if (offset > Param.Timeout)
|
||||
{
|
||||
YooLogger.Warning($"Web file request timeout : {_requestURL}");
|
||||
YooLogger.Warning($"Download request timeout : {_requestURL}");
|
||||
if (_webRequest != null)
|
||||
_webRequest.Abort();
|
||||
_isAbort = true;
|
||||
@@ -126,5 +126,19 @@ namespace YooAsset
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否请求的本地文件
|
||||
/// </summary>
|
||||
protected bool IsRequestLocalFile()
|
||||
{
|
||||
//TODO : UNITY_STANDALONE_OSX平台目前无法确定
|
||||
if (Param.MainURL.StartsWith("file:"))
|
||||
return true;
|
||||
if (Param.MainURL.StartsWith("jar:file:"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user