AlicizaX/Client/Assets/Scripts/Startup/Framework/Procedure/ProcedureGetAppVersionInfoState.cs
2025-04-28 19:45:45 +08:00

57 lines
1.5 KiB
C#

using System;
using Cysharp.Threading.Tasks;
using AlicizaX;
using YooAsset;
namespace Unity.Startup.Procedure
{
/// <summary>
/// 获取版本信息
/// </summary>
public sealed class ProcedureGetAppVersionInfoState : StateBase<UpdateProcedureState>
{
protected override void OnEnter()
{
base.OnEnter();
// 编辑器下的模拟模式
if (GameApp.Resource.PlayMode == EPlayMode.EditorSimulateMode)
{
SwitchState(UpdateProcedureState.ProcedurePatchInit);
return;
}
GetAppVersionInfo();
}
private async void GetAppVersionInfo()
{
try
{
if (HttpHelper.Version != AppVersion.GameVersion)
{
Log.Warning($"Version inconsistency : {AppVersion.GameVersion}->{HttpHelper.Version} ");
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
UILoadTipWindow.ShowUILoadTip("VersionLow", () =>
{
Application.OpenURL(HttpHelper.AppDownloadUrl);
Application.Quit();
}).Forget();
#endif
return;
}
SwitchState(UpdateProcedureState.ProcedurePatchInit);
}
catch (Exception e)
{
Log.Exception(e);
await UniTask.Delay(3000);
GetAppVersionInfo();
}
}
}
}