更新优化启用UpdateData时UILoadUpdate时序的问题

更新优化启用UpdateData时UILoadUpdate时序的问题
This commit is contained in:
ALEXTANG
2023-11-02 11:48:47 +08:00
parent 0ec1424f0a
commit d66c823c15
5 changed files with 42 additions and 31 deletions

View File

@@ -38,10 +38,15 @@ namespace GameMain
m_btnClear.gameObject.SetActive(true);
}
public override void RegisterEvent()
{
base.RegisterEvent();
AddUIEvent(RuntimeId.ToRuntimeId("RefreshVersion"),RefreshVersion);
}
public override void OnRefresh()
{
base.OnRefresh();
RefreshVersion();
}
#region

View File

@@ -60,8 +60,8 @@ namespace GameMain
{
//热更新阶段文本初始化
LoadText.Instance.InitConfigData(null);
//热更新UI初始化
UILoadMgr.Initialize();
GameEvent.Send(RuntimeId.ToRuntimeId("RefreshVersion"));
EPlayMode playMode = GameModule.Resource.PlayMode;

View File

@@ -15,6 +15,9 @@ namespace GameMain
{
base.OnEnter(procedureOwner);
//热更新UI初始化
UILoadMgr.Initialize();
// 语言配置:设置当前使用的语言,如果不设置,则默认使用操作系统语言
InitLanguageSettings();

View File

@@ -22,7 +22,7 @@ namespace GameMain
base.OnEnter(procedureOwner);
UILoadMgr.Show(UIDefine.UILoadUpdate,$"更新静态版本文件...");
UILoadMgr.Show(UIDefine.UILoadUpdate, $"更新静态版本文件...");
//检查设备是否能够访问互联网
if (Application.internetReachability == NetworkReachability.NotReachable)
@@ -34,6 +34,7 @@ namespace GameMain
GetStaticVersion().Forget,
() => { ChangeState<ProcedureInitResources>(procedureOwner); });
}
UILoadMgr.Show(UIDefine.UILoadUpdate, LoadText.Instance.Label_RequestVersionIng);
// 用户尝试更新静态版本。
@@ -49,23 +50,35 @@ namespace GameMain
var operation = GameModule.Resource.UpdatePackageVersionAsync();
await operation.ToUniTask();
if (operation.Status == EOperationStatus.Succeed)
try
{
//线上最新版本operation.PackageVersion
GameModule.Resource.PackageVersion = operation.PackageVersion;
Log.Debug($"Updated package Version : from {GameModule.Resource.GetPackageVersion()} to {operation.PackageVersion}");
ChangeState<ProcedureUpdateManifest>(_procedureOwner);
}
else
{
Log.Error(operation.Error);
await operation.ToUniTask();
UILoadTip.ShowMessageBox($"用户尝试更新静态版本失败!点击确认重试 \n \n <color=#FF0000>原因{operation.Error}</color>", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { ChangeState<ProcedureUpdateVersion>(_procedureOwner); }, UnityEngine.Application.Quit);
if (operation.Status == EOperationStatus.Succeed)
{
//线上最新版本operation.PackageVersion
GameModule.Resource.PackageVersion = operation.PackageVersion;
Log.Debug($"Updated package Version : from {GameModule.Resource.GetPackageVersion()} to {operation.PackageVersion}");
ChangeState<ProcedureUpdateManifest>(_procedureOwner);
}
else
{
OnGetStaticVersionError(operation.Error);
}
}
catch (Exception e)
{
OnGetStaticVersionError(e.Message);
}
}
private void OnGetStaticVersionError(string error)
{
Log.Error(error);
UILoadTip.ShowMessageBox($"用户尝试更新静态版本失败!点击确认重试 \n \n <color=#FF0000>原因{error}</color>", MessageShowType.TwoButton,
LoadStyle.StyleEnum.Style_Retry
, () => { ChangeState<ProcedureUpdateVersion>(_procedureOwner); }, UnityEngine.Application.Quit);
}
}
}

View File

@@ -232,20 +232,10 @@ namespace TEngine
return;
}
_entity = new GameObject("[Unity.Utility]")
{
// hideFlags = HideFlags.HideAndDontSave
};
_entity = new GameObject("[Unity.Utility]");
_entity.SetActive(true);
_entity.transform.SetParent(GameModule.Base.transform);
#if UNITY_EDITOR
if (Application.isPlaying)
#endif
{
Object.DontDestroyOnLoad(_entity);
}
UnityEngine.Assertions.Assert.IsFalse(_behaviour);
_behaviour = _entity.AddComponent<MainBehaviour>();
}