mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
yoo2.2,9
yoo2.2,9
This commit is contained in:
@@ -49,8 +49,8 @@ namespace GameMain
|
||||
var downloader = GameModule.Resource.Downloader;
|
||||
|
||||
// 注册下载回调
|
||||
downloader.OnDownloadErrorCallback = OnDownloadErrorCallback;
|
||||
downloader.OnDownloadProgressCallback = OnDownloadProgressCallback;
|
||||
downloader.DownloadErrorCallback = OnDownloadErrorCallback;
|
||||
downloader.DownloadUpdateCallback = OnDownloadProgressCallback;
|
||||
downloader.BeginDownload();
|
||||
await downloader;
|
||||
|
||||
@@ -61,23 +61,23 @@ namespace GameMain
|
||||
ChangeState<ProcedureDownloadOver>(_procedureOwner);
|
||||
}
|
||||
|
||||
private void OnDownloadErrorCallback(string fileName, string error)
|
||||
private void OnDownloadErrorCallback(DownloadErrorData downloadErrorData)
|
||||
{
|
||||
UILoadTip.ShowMessageBox($"Failed to download file : {fileName}", MessageShowType.TwoButton,
|
||||
UILoadTip.ShowMessageBox($"Failed to download file : {downloadErrorData.FileName}", MessageShowType.TwoButton,
|
||||
LoadStyle.StyleEnum.Style_Default,
|
||||
() => { ChangeState<ProcedureCreateDownloader>(_procedureOwner); }, UnityEngine.Application.Quit);
|
||||
}
|
||||
|
||||
private void OnDownloadProgressCallback(int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes)
|
||||
private void OnDownloadProgressCallback(DownloadUpdateData downloadUpdateData/*int totalDownloadCount, int currentDownloadCount, long totalDownloadBytes, long currentDownloadBytes*/)
|
||||
{
|
||||
string currentSizeMb = (currentDownloadBytes / 1048576f).ToString("f1");
|
||||
string totalSizeMb = (totalDownloadBytes / 1048576f).ToString("f1");
|
||||
string currentSizeMb = (downloadUpdateData.CurrentDownloadBytes / 1048576f).ToString("f1");
|
||||
string totalSizeMb = (downloadUpdateData.TotalDownloadBytes / 1048576f).ToString("f1");
|
||||
float progressPercentage = GameModule.Resource.Downloader.Progress * 100;
|
||||
string speed = Utility.File.GetLengthString((int)CurrentSpeed);
|
||||
|
||||
string line1 = Utility.Text.Format("正在更新,已更新 {0}/{1} ({2:F2}%)", currentDownloadCount, totalDownloadCount, progressPercentage);
|
||||
string line1 = Utility.Text.Format("正在更新,已更新 {0}/{1} ({2:F2}%)", downloadUpdateData.CurrentDownloadCount, downloadUpdateData.TotalDownloadCount, progressPercentage);
|
||||
string line2 = Utility.Text.Format("已更新大小 {0}MB/{1}MB", currentSizeMb, totalSizeMb);
|
||||
string line3 = Utility.Text.Format("当前网速 {0}/s,剩余时间 {1}", speed, GetRemainingTime(totalDownloadBytes, currentDownloadBytes, CurrentSpeed));
|
||||
string line3 = Utility.Text.Format("当前网速 {0}/s,剩余时间 {1}", speed, GetRemainingTime(downloadUpdateData.TotalDownloadBytes, downloadUpdateData.CurrentDownloadBytes, CurrentSpeed));
|
||||
|
||||
LoadUpdateLogic.Instance.DownProgressAction?.Invoke(GameModule.Resource.Downloader.Progress);
|
||||
UILoadMgr.Show(UIDefine.UILoadUpdate, $"{line1}\n{line2}\n{line3}");
|
||||
|
@@ -73,7 +73,8 @@ namespace GameMain
|
||||
else if (playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
Log.Info("Package resource mode detected.");
|
||||
ChangeState<ProcedureInitResources>(procedureOwner);
|
||||
// ChangeState<ProcedureInitResources>(procedureOwner);
|
||||
ChangeState<ProcedureUpdateVersion>(procedureOwner);
|
||||
}
|
||||
// 可更新模式。
|
||||
else if (playMode == EPlayMode.HostPlayMode ||
|
||||
|
@@ -34,7 +34,7 @@ namespace GameMain
|
||||
{
|
||||
//更新成功
|
||||
//注意:保存资源版本号作为下次默认启动的版本!
|
||||
operation.SavePackageVersion();
|
||||
// operation.SavePackageVersion();
|
||||
|
||||
if (GameModule.Resource.PlayMode == EPlayMode.WebPlayMode ||
|
||||
GameModule.Resource.UpdatableWhilePlaying)
|
||||
|
@@ -24,15 +24,20 @@ namespace GameMain
|
||||
|
||||
UILoadMgr.Show(UIDefine.UILoadUpdate, $"更新静态版本文件...");
|
||||
|
||||
//检查设备是否能够访问互联网
|
||||
if (Application.internetReachability == NetworkReachability.NotReachable)
|
||||
EPlayMode playMode = GameModule.Resource.PlayMode;
|
||||
|
||||
if (playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
Log.Warning("The device is not connected to the network");
|
||||
UILoadMgr.Show(UIDefine.UILoadUpdate, LoadText.Instance.Label_Net_UnReachable);
|
||||
UILoadTip.ShowMessageBox(LoadText.Instance.Label_Net_UnReachable, MessageShowType.TwoButton,
|
||||
LoadStyle.StyleEnum.Style_Retry,
|
||||
GetStaticVersion().Forget,
|
||||
() => { ChangeState<ProcedureInitResources>(procedureOwner); });
|
||||
//检查设备是否能够访问互联网
|
||||
if (Application.internetReachability == NetworkReachability.NotReachable)
|
||||
{
|
||||
Log.Warning("The device is not connected to the network");
|
||||
UILoadMgr.Show(UIDefine.UILoadUpdate, LoadText.Instance.Label_Net_UnReachable);
|
||||
UILoadTip.ShowMessageBox(LoadText.Instance.Label_Net_UnReachable, MessageShowType.TwoButton,
|
||||
LoadStyle.StyleEnum.Style_Retry,
|
||||
GetStaticVersion().Forget,
|
||||
() => { ChangeState<ProcedureInitResources>(procedureOwner); });
|
||||
}
|
||||
}
|
||||
|
||||
UILoadMgr.Show(UIDefine.UILoadUpdate, LoadText.Instance.Label_RequestVersionIng);
|
||||
@@ -46,7 +51,11 @@ namespace GameMain
|
||||
/// </summary>
|
||||
private async UniTaskVoid GetStaticVersion()
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(0.5f));
|
||||
EPlayMode playMode = GameModule.Resource.PlayMode;
|
||||
if (playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(0.5f));
|
||||
}
|
||||
|
||||
var operation = GameModule.Resource.UpdatePackageVersionAsync();
|
||||
|
||||
@@ -59,7 +68,15 @@ namespace GameMain
|
||||
//线上最新版本operation.PackageVersion
|
||||
GameModule.Resource.PackageVersion = operation.PackageVersion;
|
||||
Log.Debug($"Updated package Version : from {GameModule.Resource.GetPackageVersion()} to {operation.PackageVersion}");
|
||||
ChangeState<ProcedureUpdateManifest>(_procedureOwner);
|
||||
|
||||
if (playMode == EPlayMode.HostPlayMode || playMode == EPlayMode.WebPlayMode)
|
||||
{
|
||||
ChangeState<ProcedureUpdateManifest>(_procedureOwner);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeState<ProcedureInitResources>(_procedureOwner);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user