AlicizaX/Client/Assets/Scripts/Startup/Framework/Procedure/ProcedureGetAppVersionInfoState.cs

64 lines
1.8 KiB
C#
Raw Normal View History

2025-01-23 19:06:48 +08:00
using System;
using Cysharp.Threading.Tasks;
using AlicizaX.Fsm.Runtime;
using AlicizaX.Procedure.Runtime;
using AlicizaX.Runtime;
using UnityEngine;
using YooAsset;
using Version = System.Version;
namespace Unity.Startup.Procedure
{
/// <summary>
/// 获取版本信息
/// </summary>
public sealed class ProcedureGetAppVersionInfoState : ProcedureBase
{
protected override void OnEnter(IFsm<IProcedureManager> procedureOwner)
{
base.OnEnter(procedureOwner);
// 编辑器下的模拟模式
if (GameApp.Resource.GamePlayMode == EPlayMode.EditorSimulateMode)
{
ChangeState<ProcedurePatchInit>(procedureOwner);
return;
}
GetAppVersionInfo(procedureOwner);
}
private async void GetAppVersionInfo(IFsm<IProcedureManager> procedureOwner)
{
try
{
2025-03-07 18:00:59 +08:00
if (GlobalSetting.PatchData == null)
2025-01-23 19:06:48 +08:00
{
Log.Error("GlobalConfig PatchData Is Null!");
return;
}
2025-03-07 18:00:59 +08:00
if (GlobalSetting.PatchData.Version != AppVersion.GameVersion)
2025-01-23 19:06:48 +08:00
{
2025-03-07 18:00:59 +08:00
Log.Warning($"Version inconsistency : {AppVersion.GameVersion}->{GlobalSetting.PatchData.Version} ");
2025-01-23 19:06:48 +08:00
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.OpenURL(GlobalConfig.PatchData.AppDownloadUrl);
Application.Quit();
#endif
return;
}
ChangeState<ProcedurePatchInit>(procedureOwner);
}
catch (Exception e)
{
Log.Error(e);
await UniTask.Delay(3000);
GetAppVersionInfo(procedureOwner);
}
}
}
2025-01-26 20:55:39 +08:00
}