Update runtime logic

UpdatePackageVersionAsync()方法增加appendTimeTicks参数
pull/62/head
hevinci 2022-12-03 20:03:10 +08:00
parent a290353cfa
commit 688cc271d5
3 changed files with 13 additions and 7 deletions

View File

@ -202,7 +202,8 @@ namespace YooAsset
/// 向网络端请求最新的资源版本 /// 向网络端请求最新的资源版本
/// </summary> /// </summary>
/// <param name="timeout">超时时间默认值60秒</param> /// <param name="timeout">超时时间默认值60秒</param>
public UpdatePackageVersionOperation UpdatePackageVersionAsync(int timeout = 60) /// <param name="appendTimeTicks">在URL末尾添加时间戳</param>
public UpdatePackageVersionOperation UpdatePackageVersionAsync(int timeout = 60, bool appendTimeTicks = true)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
if (_playMode == EPlayMode.EditorSimulateMode) if (_playMode == EPlayMode.EditorSimulateMode)
@ -219,7 +220,7 @@ namespace YooAsset
} }
else if (_playMode == EPlayMode.HostPlayMode) else if (_playMode == EPlayMode.HostPlayMode)
{ {
return _hostPlayModeImpl.UpdatePackageVersionAsync(PackageName, timeout); return _hostPlayModeImpl.UpdatePackageVersionAsync(PackageName, timeout, appendTimeTicks);
} }
else else
{ {

View File

@ -60,14 +60,16 @@ namespace YooAsset
private readonly HostPlayModeImpl _impl; private readonly HostPlayModeImpl _impl;
private readonly string _packageName; private readonly string _packageName;
private readonly int _timeout; private readonly int _timeout;
private readonly bool _appendTimeTicks;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
private UnityWebDataRequester _downloader; private UnityWebDataRequester _downloader;
internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, int timeout) internal HostPlayModeUpdatePackageVersionOperation(HostPlayModeImpl impl, string packageName, int timeout, bool appendTimeTicks)
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
_timeout = timeout; _timeout = timeout;
_appendTimeTicks = appendTimeTicks;
} }
internal override void Start() internal override void Start()
{ {
@ -130,8 +132,11 @@ namespace YooAsset
else else
url = _impl.GetPatchDownloadMainURL(fileName); url = _impl.GetPatchDownloadMainURL(fileName);
// 注意在URL末尾添加时间戳 // 在URL末尾添加时间戳
if (_appendTimeTicks)
return $"{url}?{System.DateTime.UtcNow.Ticks}"; return $"{url}?{System.DateTime.UtcNow.Ticks}";
else
return url;
} }
} }
} }

View File

@ -44,9 +44,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 异步更新资源版本号 /// 异步更新资源版本号
/// </summary> /// </summary>
public UpdatePackageVersionOperation UpdatePackageVersionAsync(string packageName, int timeout) public UpdatePackageVersionOperation UpdatePackageVersionAsync(string packageName, int timeout, bool appendTimeTicks)
{ {
var operation = new HostPlayModeUpdatePackageVersionOperation(this, packageName, timeout); var operation = new HostPlayModeUpdatePackageVersionOperation(this, packageName, timeout, appendTimeTicks);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }