2022-03-01 10:44:12 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2022-05-02 23:15:09 +08:00
|
|
|
|
using System.IO;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace YooAsset
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化操作
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public abstract class InitializationOperation : AsyncOperationBase
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-05-05 21:12:44 +08:00
|
|
|
|
/// 编辑器下模拟模式的初始化操作
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// </summary>
|
2022-05-05 21:12:44 +08:00
|
|
|
|
internal sealed class EditorSimulateModeInitializationOperation : InitializationOperation
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-05-02 23:15:09 +08:00
|
|
|
|
private enum ESteps
|
|
|
|
|
|
{
|
|
|
|
|
|
None,
|
|
|
|
|
|
Builder,
|
2022-05-07 19:20:52 +08:00
|
|
|
|
Load,
|
2022-05-02 23:15:09 +08:00
|
|
|
|
Done,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-05 21:12:44 +08:00
|
|
|
|
private readonly EditorSimulateModeImpl _impl;
|
2022-05-07 19:20:52 +08:00
|
|
|
|
private string _simulatePatchManifestPath;
|
2022-05-02 23:15:09 +08:00
|
|
|
|
private ESteps _steps = ESteps.None;
|
|
|
|
|
|
|
2022-05-07 19:20:52 +08:00
|
|
|
|
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulatePatchManifestPath)
|
2022-05-02 23:15:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
_impl = impl;
|
2022-05-07 19:20:52 +08:00
|
|
|
|
_simulatePatchManifestPath = simulatePatchManifestPath;
|
2022-05-02 23:15:09 +08:00
|
|
|
|
}
|
2022-03-01 10:44:12 +08:00
|
|
|
|
internal override void Start()
|
|
|
|
|
|
{
|
2022-05-07 19:20:52 +08:00
|
|
|
|
if (string.IsNullOrEmpty(_simulatePatchManifestPath))
|
|
|
|
|
|
_steps = ESteps.Builder;
|
|
|
|
|
|
else
|
|
|
|
|
|
_steps = ESteps.Load;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
internal override void Update()
|
|
|
|
|
|
{
|
2022-05-02 23:15:09 +08:00
|
|
|
|
if (_steps == ESteps.Builder)
|
|
|
|
|
|
{
|
2022-05-07 19:20:52 +08:00
|
|
|
|
_simulatePatchManifestPath = EditorSimulateModeHelper.SimulateBuild();
|
|
|
|
|
|
if (string.IsNullOrEmpty(_simulatePatchManifestPath))
|
2022-05-02 23:15:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2022-05-05 23:11:26 +08:00
|
|
|
|
Error = "Simulate build failed, see the detail info on the console window.";
|
2022-05-02 23:15:09 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
2022-05-07 19:20:52 +08:00
|
|
|
|
_steps = ESteps.Load;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.Load)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (File.Exists(_simulatePatchManifestPath) == false)
|
2022-05-02 23:15:09 +08:00
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
2022-05-07 19:20:52 +08:00
|
|
|
|
Error = $"Manifest file not found : {_simulatePatchManifestPath}";
|
2022-05-02 23:15:09 +08:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-07 19:20:52 +08:00
|
|
|
|
YooLogger.Log($"Load manifest file : {_simulatePatchManifestPath}");
|
|
|
|
|
|
string jsonContent = FileUtility.ReadFile(_simulatePatchManifestPath);
|
2022-05-05 23:11:26 +08:00
|
|
|
|
var simulatePatchManifest = PatchManifest.Deserialize(jsonContent);
|
|
|
|
|
|
_impl.SetSimulatePatchManifest(simulatePatchManifest);
|
2022-05-02 23:15:09 +08:00
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Succeed;
|
|
|
|
|
|
}
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-05-05 21:12:44 +08:00
|
|
|
|
/// 离线运行模式的初始化操作
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// </summary>
|
2022-04-21 16:16:40 +08:00
|
|
|
|
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
private enum ESteps
|
|
|
|
|
|
{
|
2022-03-03 18:07:20 +08:00
|
|
|
|
None,
|
2022-04-12 19:15:44 +08:00
|
|
|
|
Update,
|
2022-03-01 10:44:12 +08:00
|
|
|
|
Done,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
private readonly OfflinePlayModeImpl _impl;
|
|
|
|
|
|
private readonly AppManifestLoader _appManifestLoader = new AppManifestLoader();
|
2022-03-03 18:07:20 +08:00
|
|
|
|
private ESteps _steps = ESteps.None;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
|
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl)
|
|
|
|
|
|
{
|
|
|
|
|
|
_impl = impl;
|
|
|
|
|
|
}
|
|
|
|
|
|
internal override void Start()
|
|
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
_steps = ESteps.Update;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
internal override void Update()
|
|
|
|
|
|
{
|
2022-03-03 18:07:20 +08:00
|
|
|
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
return;
|
2022-05-02 15:03:36 +08:00
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_steps == ESteps.Update)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
_appManifestLoader.Update();
|
2022-05-07 20:30:16 +08:00
|
|
|
|
Progress = _appManifestLoader.Progress();
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_appManifestLoader.IsDone() == false)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_appManifestLoader.Result == null)
|
2022-05-02 15:03:36 +08:00
|
|
|
|
{
|
2022-03-01 10:44:12 +08:00
|
|
|
|
_steps = ESteps.Done;
|
2022-03-03 18:07:20 +08:00
|
|
|
|
Status = EOperationStatus.Failed;
|
2022-04-12 19:15:44 +08:00
|
|
|
|
Error = _appManifestLoader.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Succeed;
|
2022-05-05 23:11:26 +08:00
|
|
|
|
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-05-05 21:12:44 +08:00
|
|
|
|
/// 网络运行模式的初始化操作
|
2022-03-01 10:44:12 +08:00
|
|
|
|
/// </summary>
|
2022-04-21 16:16:40 +08:00
|
|
|
|
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
private enum ESteps
|
|
|
|
|
|
{
|
2022-03-03 18:07:20 +08:00
|
|
|
|
None,
|
2022-03-01 10:44:12 +08:00
|
|
|
|
InitCache,
|
2022-06-29 11:59:39 +08:00
|
|
|
|
LoadManifest,
|
|
|
|
|
|
CopyManifest,
|
2022-03-01 10:44:12 +08:00
|
|
|
|
Done,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
private readonly HostPlayModeImpl _impl;
|
|
|
|
|
|
private readonly AppManifestLoader _appManifestLoader = new AppManifestLoader();
|
2022-06-29 11:59:39 +08:00
|
|
|
|
private readonly AppManifestCopyer _appManifestCopyer = new AppManifestCopyer();
|
2022-03-03 18:07:20 +08:00
|
|
|
|
private ESteps _steps = ESteps.None;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
|
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl)
|
|
|
|
|
|
{
|
|
|
|
|
|
_impl = impl;
|
|
|
|
|
|
}
|
|
|
|
|
|
internal override void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.InitCache;
|
|
|
|
|
|
}
|
|
|
|
|
|
internal override void Update()
|
|
|
|
|
|
{
|
2022-03-03 18:07:20 +08:00
|
|
|
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.InitCache)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 每次启动时比对APP版本号是否一致
|
2022-05-02 15:03:36 +08:00
|
|
|
|
CacheData cacheData = CacheData.LoadCache();
|
|
|
|
|
|
if (cacheData.CacheAppVersion != Application.version)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-05-02 15:03:36 +08:00
|
|
|
|
YooLogger.Warning($"Cache is dirty ! Cache application version is {cacheData.CacheAppVersion}, Current application version is {Application.version}");
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
|
|
|
|
|
// 注意:在覆盖安装的时候,会保留APP沙盒目录,可以选择清空缓存目录
|
|
|
|
|
|
if (_impl.ClearCacheWhenDirty)
|
|
|
|
|
|
{
|
2022-03-09 21:53:01 +08:00
|
|
|
|
YooLogger.Warning("Clear cache files.");
|
2022-05-02 15:03:36 +08:00
|
|
|
|
SandboxHelper.DeleteCacheFolder();
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 更新缓存文件
|
2022-05-02 15:03:36 +08:00
|
|
|
|
CacheData.UpdateCache();
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-06-29 11:59:39 +08:00
|
|
|
|
_steps = ESteps.LoadManifest;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-29 11:59:39 +08:00
|
|
|
|
if (_steps == ESteps.LoadManifest)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
_appManifestLoader.Update();
|
2022-05-07 20:30:16 +08:00
|
|
|
|
Progress = _appManifestLoader.Progress();
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_appManifestLoader.IsDone() == false)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
return;
|
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_appManifestLoader.Result == null)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
2022-03-03 18:07:20 +08:00
|
|
|
|
Status = EOperationStatus.Failed;
|
2022-04-12 19:15:44 +08:00
|
|
|
|
Error = _appManifestLoader.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-05-05 23:11:26 +08:00
|
|
|
|
_impl.SetAppPatchManifest(_appManifestLoader.Result);
|
|
|
|
|
|
_impl.SetLocalPatchManifest(_appManifestLoader.Result);
|
2022-06-29 11:59:39 +08:00
|
|
|
|
_appManifestCopyer.Init(_appManifestLoader.StaticVersion);
|
|
|
|
|
|
_steps = ESteps.CopyManifest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.CopyManifest)
|
|
|
|
|
|
{
|
|
|
|
|
|
_appManifestCopyer.Update();
|
|
|
|
|
|
if (_appManifestCopyer.IsDone() == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_appManifestCopyer.Result == false)
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
|
Error = _appManifestCopyer.Error;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
Status = EOperationStatus.Succeed;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-04-12 19:15:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
2022-05-02 23:15:09 +08:00
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 内置补丁清单加载器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class AppManifestLoader
|
|
|
|
|
|
{
|
|
|
|
|
|
private enum ESteps
|
|
|
|
|
|
{
|
|
|
|
|
|
LoadStaticVersion,
|
|
|
|
|
|
CheckStaticVersion,
|
|
|
|
|
|
LoadAppManifest,
|
|
|
|
|
|
CheckAppManifest,
|
2022-06-29 11:59:39 +08:00
|
|
|
|
Done,
|
2022-04-12 19:15:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ESteps _steps = ESteps.LoadStaticVersion;
|
|
|
|
|
|
private UnityWebDataRequester _downloader1;
|
|
|
|
|
|
private UnityWebDataRequester _downloader2;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 错误日志
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Error { private set; get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2022-06-29 11:59:39 +08:00
|
|
|
|
/// 加载结果
|
2022-04-12 19:15:44 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
public PatchManifest Result { private set; get; }
|
|
|
|
|
|
|
2022-06-29 11:59:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 内置补丁清单版本号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public int StaticVersion { private set; get; }
|
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否已经完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsDone()
|
|
|
|
|
|
{
|
2022-06-29 11:59:39 +08:00
|
|
|
|
return _steps == ESteps.Done;
|
2022-04-12 19:15:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-05-07 20:30:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 加载进度
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public float Progress()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloader2 == null)
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
return _downloader2.Progress();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-06-29 11:59:39 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新流程
|
|
|
|
|
|
/// </summary>
|
2022-04-12 19:15:44 +08:00
|
|
|
|
public void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsDone())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.LoadStaticVersion)
|
|
|
|
|
|
{
|
|
|
|
|
|
YooLogger.Log($"Load application static version.");
|
|
|
|
|
|
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettings.VersionFileName);
|
|
|
|
|
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
|
|
|
|
|
_downloader1 = new UnityWebDataRequester();
|
|
|
|
|
|
_downloader1.SendRequest(url);
|
|
|
|
|
|
_steps = ESteps.CheckStaticVersion;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_steps == ESteps.CheckStaticVersion)
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_downloader1.IsDone() == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_downloader1.HasError())
|
2022-03-01 10:44:12 +08:00
|
|
|
|
{
|
2022-04-12 19:15:44 +08:00
|
|
|
|
Error = _downloader1.GetError();
|
2022-06-29 11:59:39 +08:00
|
|
|
|
_steps = ESteps.Done;
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
2022-04-12 19:15:44 +08:00
|
|
|
|
else
|
|
|
|
|
|
{
|
2022-06-29 11:59:39 +08:00
|
|
|
|
StaticVersion = int.Parse(_downloader1.GetText());
|
2022-04-12 19:15:44 +08:00
|
|
|
|
_steps = ESteps.LoadAppManifest;
|
|
|
|
|
|
}
|
|
|
|
|
|
_downloader1.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.LoadAppManifest)
|
|
|
|
|
|
{
|
|
|
|
|
|
YooLogger.Log($"Load application patch manifest.");
|
2022-06-29 11:59:39 +08:00
|
|
|
|
string filePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(StaticVersion));
|
2022-04-12 19:15:44 +08:00
|
|
|
|
string url = PathHelper.ConvertToWWWPath(filePath);
|
|
|
|
|
|
_downloader2 = new UnityWebDataRequester();
|
|
|
|
|
|
_downloader2.SendRequest(url);
|
|
|
|
|
|
_steps = ESteps.CheckAppManifest;
|
|
|
|
|
|
}
|
2022-03-01 10:44:12 +08:00
|
|
|
|
|
2022-04-12 19:15:44 +08:00
|
|
|
|
if (_steps == ESteps.CheckAppManifest)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloader2.IsDone() == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_downloader2.HasError())
|
|
|
|
|
|
{
|
2022-05-02 15:03:36 +08:00
|
|
|
|
Error = _downloader2.GetError();
|
2022-06-29 11:59:39 +08:00
|
|
|
|
_steps = ESteps.Done;
|
2022-04-12 19:15:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
// 解析APP里的补丁清单
|
|
|
|
|
|
Result = PatchManifest.Deserialize(_downloader2.GetText());
|
2022-06-29 11:59:39 +08:00
|
|
|
|
_steps = ESteps.Done;
|
2022-04-12 19:15:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
_downloader2.Dispose();
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-06-29 11:59:39 +08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 内置补丁清单复制器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class AppManifestCopyer
|
|
|
|
|
|
{
|
|
|
|
|
|
private enum ESteps
|
|
|
|
|
|
{
|
|
|
|
|
|
CopyAppManifest,
|
|
|
|
|
|
CheckAppManifest,
|
|
|
|
|
|
Done,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ESteps _steps = ESteps.CopyAppManifest;
|
|
|
|
|
|
private UnityWebFileRequester _downloader1;
|
|
|
|
|
|
private int _staticVersion;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 错误日志
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string Error { private set; get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 拷贝结果
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool Result { private set; get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 是否已经完成
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsDone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return _steps == ESteps.Done;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 初始化流程
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Init(int staticVersion)
|
|
|
|
|
|
{
|
|
|
|
|
|
_staticVersion = staticVersion;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新流程
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (IsDone())
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.CopyAppManifest)
|
|
|
|
|
|
{
|
|
|
|
|
|
string destFilePath = PathHelper.MakePersistentLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
|
|
|
|
|
|
if (File.Exists(destFilePath))
|
|
|
|
|
|
{
|
|
|
|
|
|
Result = true;
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
YooLogger.Log($"Copy application patch manifest.");
|
|
|
|
|
|
string sourceFilePath = PathHelper.MakeStreamingLoadPath(YooAssetSettingsData.GetPatchManifestFileName(_staticVersion));
|
|
|
|
|
|
string url = PathHelper.ConvertToWWWPath(sourceFilePath);
|
|
|
|
|
|
_downloader1 = new UnityWebFileRequester();
|
|
|
|
|
|
_downloader1.SendRequest(url, destFilePath);
|
|
|
|
|
|
_steps = ESteps.CheckAppManifest;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.CheckAppManifest)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_downloader1.IsDone() == false)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (_downloader1.HasError())
|
|
|
|
|
|
{
|
|
|
|
|
|
Result = false;
|
|
|
|
|
|
Error = _downloader1.GetError();
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Result = true;
|
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
|
}
|
|
|
|
|
|
_downloader1.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-03-01 10:44:12 +08:00
|
|
|
|
}
|