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

56 lines
1.4 KiB
C#
Raw Normal View History

2025-01-23 19:06:48 +08:00
using System;
using Cysharp.Threading.Tasks;
2025-04-28 19:45:45 +08:00
using AlicizaX;
2025-10-14 15:42:34 +08:00
using UnityEngine;
2025-01-23 19:06:48 +08:00
using YooAsset;
namespace Unity.Startup.Procedure
{
/// <summary>
/// 获取版本信息
/// </summary>
2025-11-18 16:15:26 +08:00
public sealed class ProcedureGetAppVersionInfoState : ProcedureBase
2025-01-23 19:06:48 +08:00
{
2026-03-11 15:23:50 +08:00
private const int MaxTryCount = 3;
private int currentTryCount;
2025-04-28 19:45:45 +08:00
protected override void OnEnter()
2025-01-23 19:06:48 +08:00
{
2025-04-28 19:45:45 +08:00
base.OnEnter();
GetAppVersionInfo();
2025-01-23 19:06:48 +08:00
}
2025-04-28 19:45:45 +08:00
private async void GetAppVersionInfo()
2025-01-23 19:06:48 +08:00
{
try
{
2026-03-11 15:23:50 +08:00
currentTryCount++;
2026-03-11 14:18:25 +08:00
if (StartupSetting.Version != AppVersion.GameVersion)
2025-01-23 19:06:48 +08:00
{
2026-03-11 14:18:25 +08:00
Log.Warning($"Version inconsistency : {AppVersion.GameVersion}->{StartupSetting.Version} ");
2026-03-23 20:50:25 +08:00
Utility.Platform.Quit();
2026-04-15 09:39:38 +08:00
#if !UNITY_EDITOR
Utility.Platform.OpenURL(StartupSetting.AppDownloadUrl);
2025-01-23 19:06:48 +08:00
#endif
return;
}
2026-03-11 15:23:50 +08:00
2025-11-18 16:15:26 +08:00
SwitchProcedure<ProcedureInitPackageState>();
2025-01-23 19:06:48 +08:00
}
catch (Exception e)
{
2025-04-28 19:45:45 +08:00
Log.Exception(e);
2026-04-14 11:24:09 +08:00
currentTryCount++;
if (currentTryCount <= MaxTryCount)
2026-03-11 15:23:50 +08:00
{
2026-04-14 11:24:09 +08:00
await UniTask.Delay(3000);
GetAppVersionInfo();
2026-03-11 15:23:50 +08:00
}
2025-01-23 19:06:48 +08:00
}
}
}
2025-01-26 20:55:39 +08:00
}