diff --git a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs
index 70cd977..953ae61 100644
--- a/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs
+++ b/Assets/YooAsset/Editor/AssetBundleDebugger/VisualViewers/DebuggerBundleListViewer.cs
@@ -189,7 +189,7 @@ namespace YooAsset.Editor
// Status
StyleColor textColor;
- if (bundleInfo.Status == BundleFileLoader.EStatus.Failed.ToString())
+ if (bundleInfo.Status == EOperationStatus.Failed)
textColor = new StyleColor(Color.yellow);
else
textColor = label1.style.color;
diff --git a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs
index fa564c4..dcf34c3 100644
--- a/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs
+++ b/Assets/YooAsset/Runtime/DiagnosticSystem/DebugBundleInfo.cs
@@ -25,7 +25,7 @@ namespace YooAsset
///
/// 加载状态
///
- public string Status;
+ public EOperationStatus Status;
public int CompareTo(DebugBundleInfo other)
{
diff --git a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs
index 16534c6..55a7a9b 100644
--- a/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs
+++ b/Assets/YooAsset/Runtime/DownloadSystem/DownloadSystemHelper.cs
@@ -43,7 +43,7 @@ namespace YooAsset
#elif UNITY_OPENHARMONY
return StringUtility.Format("file://{0}", path);
#else
- return path;
+ throw new System.NotImplementedException();
#endif
}
}
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSLoadBundleOperation.cs
index e17ef8e..e5f52fc 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSLoadBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultBuildinFileSystem/Operation/DBFSLoadBundleOperation.cs
@@ -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()
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSDownloadFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSDownloadFileOperation.cs
index fefeb0a..e5bf7d2 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSDownloadFileOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSDownloadFileOperation.cs
@@ -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;
}
}
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSLoadBundleOperation.cs
index 879d726..46460aa 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSLoadBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/DCFSLoadBundleOperation.cs
@@ -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()
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/VerifyTempFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/VerifyTempFileOperation.cs
index 18e4888..cd4a101 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/VerifyTempFileOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/VerifyTempFileOperation.cs
@@ -85,14 +85,12 @@ namespace YooAsset
}
}
}
- public override void WaitForAsyncComplete()
+ internal override void InternalWaitForAsyncComplete()
{
while (true)
{
- // 驱动流程
+ // 注意:等待子线程验证文件完毕
InternalOnUpdate();
-
- // 完成后退出
if (IsDone)
break;
}
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs
index c5119f1..ed20925 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs
@@ -20,8 +20,7 @@ namespace YooAsset
internal override void InternalOnUpdate()
{
}
-
- public override void WaitForAsyncComplete()
+ internal override void InternalWaitForAsyncComplete()
{
}
public override void AbortDownloadOperation()
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/DefaultUnpackFileSystem.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/DefaultUnpackFileSystem.cs
index ebb6776..edc3ad1 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/DefaultUnpackFileSystem.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/DefaultUnpackFileSystem.cs
@@ -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;
- }
- }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation.meta b/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation.meta
deleted file mode 100644
index ab868c7..0000000
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation.meta
+++ /dev/null
@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 59b123e460757694180175970bf28826
-folderAsset: yes
-DefaultImporter:
- externalObjects: {}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation/DUFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation/DUFSLoadBundleOperation.cs
deleted file mode 100644
index c2bab46..0000000
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation/DUFSLoadBundleOperation.cs
+++ /dev/null
@@ -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;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation/DUFSLoadBundleOperation.cs.meta b/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation/DUFSLoadBundleOperation.cs.meta
deleted file mode 100644
index 2015b9e..0000000
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultUnpackFileSystem/Operation/DUFSLoadBundleOperation.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 47f6fe3a815d28e49815db7c09c1fa76
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/YooAsset/Runtime/FileSystem/DefaultWebFileSystem/Operation/DWFSLoadBundleOperation.cs b/Assets/YooAsset/Runtime/FileSystem/DefaultWebFileSystem/Operation/DWFSLoadBundleOperation.cs
index ed99327..fe4f8f6 100644
--- a/Assets/YooAsset/Runtime/FileSystem/DefaultWebFileSystem/Operation/DWFSLoadBundleOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/DefaultWebFileSystem/Operation/DWFSLoadBundleOperation.cs
@@ -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;
diff --git a/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DefaultDownloadFileOperation.cs b/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DefaultDownloadFileOperation.cs
index c92ae04..976ebf6 100644
--- a/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DefaultDownloadFileOperation.cs
+++ b/Assets/YooAsset/Runtime/FileSystem/Operation/Internal/DefaultDownloadFileOperation.cs
@@ -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
}
+
+ ///
+ /// 是否请求的本地文件
+ ///
+ protected bool IsRequestLocalFile()
+ {
+ //TODO : UNITY_STANDALONE_OSX平台目前无法确定
+ if (Param.MainURL.StartsWith("file:"))
+ return true;
+ if (Param.MainURL.StartsWith("jar:file:"))
+ return true;
+
+ return false;
+ }
}
}
\ No newline at end of file
diff --git a/Assets/YooAsset/Runtime/InitializeParameters.cs b/Assets/YooAsset/Runtime/InitializeParameters.cs
index ebc63d6..72d62e2 100644
--- a/Assets/YooAsset/Runtime/InitializeParameters.cs
+++ b/Assets/YooAsset/Runtime/InitializeParameters.cs
@@ -175,10 +175,6 @@ namespace YooAsset
///
public abstract class InitializeParameters
{
- ///
- /// 自动销毁不再使用的资源提供者
- ///
- public bool AutoDestroyAssetProvider = false;
}
///
diff --git a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
index 29302c5..cd26f90 100644
--- a/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
+++ b/Assets/YooAsset/Runtime/OperationSystem/AsyncOperationBase.cs
@@ -8,13 +8,13 @@ namespace YooAsset
{
public abstract class AsyncOperationBase : IEnumerator, IComparable
{
- // 用户请求的回调
private Action _callback;
-
- // 所属包裹
private string _packageName = null;
+ private int _whileFrame = 1000;
- // 是否已经完成
+ ///
+ /// 是否已经完成
+ ///
internal bool IsFinish = false;
///
@@ -85,7 +85,13 @@ namespace YooAsset
internal abstract void InternalOnStart();
internal abstract void InternalOnUpdate();
- internal virtual void InternalOnAbort() { }
+ internal virtual void InternalOnAbort()
+ {
+ }
+ internal virtual void InternalWaitForAsyncComplete()
+ {
+ throw new System.NotImplementedException(this.GetType().Name);
+ }
internal string GetPackageName()
{
@@ -125,19 +131,36 @@ namespace YooAsset
}
///
- /// 等待异步执行完毕
+ /// 执行While循环
///
- public virtual void WaitForAsyncComplete()
+ protected bool ExecuteWhileDone()
{
- throw new System.NotImplementedException(this.GetType().Name);
+ if (IsDone == false)
+ {
+ // 执行更新逻辑
+ InternalOnUpdate();
+
+ // 当执行次数用完时
+ _whileFrame--;
+ if (_whileFrame == 0)
+ {
+ Status = EOperationStatus.Failed;
+ Error = $"Operation {this.GetType().Name} failed to wait for async complete !";
+ YooLogger.Error(Error);
+ }
+ }
+ return IsDone;
}
///
- /// 清空完成回调
+ /// 等待异步执行完毕
///
- protected void ClearCompletedCallback()
+ public void WaitForAsyncComplete()
{
- _callback = null;
+ if (IsDone)
+ return;
+
+ InternalWaitForAsyncComplete();
}
#region 排序接口实现
@@ -159,19 +182,5 @@ namespace YooAsset
private TaskCompletionSource