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