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

48 lines
1.2 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
{
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 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} ");
2025-01-23 19:06:48 +08:00
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
2026-03-11 14:18:25 +08:00
Application.OpenURL(StartupSetting.AppDownloadUrl);
2025-10-14 15:42:34 +08:00
Application.Quit();
2025-01-23 19:06:48 +08:00
#endif
2025-10-14 15:42:34 +08:00
2025-01-23 19:06:48 +08:00
return;
}
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);
2025-01-23 19:06:48 +08:00
await UniTask.Delay(3000);
2025-04-28 19:45:45 +08:00
GetAppVersionInfo();
2025-01-23 19:06:48 +08:00
}
}
}
2025-01-26 20:55:39 +08:00
}