mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-19 06:40:21 +00:00
update mini game sample
This commit is contained in:
@@ -15,7 +15,7 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
|
||||
|
||||
private readonly TiktokFileSystem _fileSystem;
|
||||
private readonly DownloadFileOptions _options;
|
||||
private UnityWebCacheRequestOperation _unityWebCacheRequestOp;
|
||||
private UnityWebCacheRequestOperation _webCacheRequestOp;
|
||||
private int _requestCount = 0;
|
||||
private float _tryAgainTimer;
|
||||
private int _failedTryAgain;
|
||||
@@ -36,21 +36,23 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
string url = GetRequestURL();
|
||||
_unityWebCacheRequestOp = new UnityWebCacheRequestOperation(url);
|
||||
_unityWebCacheRequestOp.StartOperation();
|
||||
_webCacheRequestOp = new UnityWebCacheRequestOperation(url);
|
||||
_webCacheRequestOp.StartOperation();
|
||||
AddChildOperation(_webCacheRequestOp);
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckRequest)
|
||||
{
|
||||
Progress = _unityWebCacheRequestOp.Progress;
|
||||
DownloadProgress = _unityWebCacheRequestOp.DownloadProgress;
|
||||
DownloadedBytes = (long)_unityWebCacheRequestOp.DownloadedBytes;
|
||||
if (_unityWebCacheRequestOp.IsDone == false)
|
||||
_webCacheRequestOp.UpdateOperation();
|
||||
Progress = _webCacheRequestOp.Progress;
|
||||
DownloadProgress = _webCacheRequestOp.DownloadProgress;
|
||||
DownloadedBytes = (long)_webCacheRequestOp.DownloadedBytes;
|
||||
if (_webCacheRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_unityWebCacheRequestOp.Status == EOperationStatus.Succeed)
|
||||
if (_webCacheRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
@@ -65,13 +67,13 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
|
||||
if (_failedTryAgain > 0)
|
||||
{
|
||||
_steps = ESteps.TryAgain;
|
||||
YooLogger.Warning($"Failed download : {_unityWebCacheRequestOp.URL} Try again !");
|
||||
YooLogger.Warning($"Failed download : {_webCacheRequestOp.URL} Try again !");
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _unityWebCacheRequestOp.Error;
|
||||
Error = _webCacheRequestOp.Error;
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
||||
}
|
||||
|
||||
_loadWebAssetBundleOp.UpdateOperation();
|
||||
Progress = _loadWebAssetBundleOp.Progress;
|
||||
DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
|
||||
DownloadedBytes = (long)_loadWebAssetBundleOp.DownloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
if (_loadWebAssetBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ internal class WXFSDownloadFileOperation : FSDownloadFileOperation
|
||||
|
||||
private readonly WechatFileSystem _fileSystem;
|
||||
private readonly DownloadFileOptions _options;
|
||||
private UnityWebCacheRequestOperation _unityWebCacheRequestOp;
|
||||
private UnityWebCacheRequestOperation _webCacheRequestOp;
|
||||
private int _requestCount = 0;
|
||||
private float _tryAgainTimer;
|
||||
private int _failedTryAgain;
|
||||
@@ -36,24 +36,24 @@ internal class WXFSDownloadFileOperation : FSDownloadFileOperation
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
string url = GetRequestURL();
|
||||
_unityWebCacheRequestOp = new UnityWebCacheRequestOperation(url);
|
||||
_unityWebCacheRequestOp.SetRequestHeader("wechatminigame-preload", "1");
|
||||
_unityWebCacheRequestOp.StartOperation();
|
||||
AddChildOperation(_unityWebCacheRequestOp);
|
||||
_webCacheRequestOp = new UnityWebCacheRequestOperation(url);
|
||||
_webCacheRequestOp.SetRequestHeader("wechatminigame-preload", "1");
|
||||
_webCacheRequestOp.StartOperation();
|
||||
AddChildOperation(_webCacheRequestOp);
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckRequest)
|
||||
{
|
||||
_unityWebCacheRequestOp.UpdateOperation();
|
||||
Progress = _unityWebCacheRequestOp.Progress;
|
||||
DownloadProgress = _unityWebCacheRequestOp.DownloadProgress;
|
||||
DownloadedBytes = (long)_unityWebCacheRequestOp.DownloadedBytes;
|
||||
if (_unityWebCacheRequestOp.IsDone == false)
|
||||
_webCacheRequestOp.UpdateOperation();
|
||||
Progress = _webCacheRequestOp.Progress;
|
||||
DownloadProgress = _webCacheRequestOp.DownloadProgress;
|
||||
DownloadedBytes = (long)_webCacheRequestOp.DownloadedBytes;
|
||||
if (_webCacheRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_unityWebCacheRequestOp.Status == EOperationStatus.Succeed)
|
||||
if (_webCacheRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
@@ -69,13 +69,13 @@ internal class WXFSDownloadFileOperation : FSDownloadFileOperation
|
||||
if (_failedTryAgain > 0)
|
||||
{
|
||||
_steps = ESteps.TryAgain;
|
||||
YooLogger.Warning($"Failed download : {_unityWebCacheRequestOp.URL} Try again !");
|
||||
YooLogger.Warning($"Failed download : {_webCacheRequestOp.URL} Try again !");
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _unityWebCacheRequestOp.Error;
|
||||
Error = _webCacheRequestOp.Error;
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ internal class WXFSLoadBundleOperation : FSLoadBundleOperation
|
||||
}
|
||||
|
||||
_loadWebAssetBundleOp.UpdateOperation();
|
||||
Progress = _loadWebAssetBundleOp.Progress;
|
||||
DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
|
||||
DownloadedBytes = (long)_loadWebAssetBundleOp.DownloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
if (_loadWebAssetBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
|
||||
@@ -96,12 +96,6 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
if (_unityWechatAssetBundleRequestOp != null)
|
||||
_unityWechatAssetBundleRequestOp.AbortOperation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取网络请求地址
|
||||
|
||||
Reference in New Issue
Block a user