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

57 lines
1.5 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-01-23 19:06:48 +08:00
using YooAsset;
namespace Unity.Startup.Procedure
{
/// <summary>
/// 获取版本信息
/// </summary>
2025-04-28 19:45:45 +08:00
public sealed class ProcedureGetAppVersionInfoState : StateBase<UpdateProcedureState>
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();
2025-01-23 19:06:48 +08:00
// 编辑器下的模拟模式
2025-04-28 19:45:45 +08:00
if (GameApp.Resource.PlayMode == EPlayMode.EditorSimulateMode)
2025-01-23 19:06:48 +08:00
{
2025-04-28 19:45:45 +08:00
SwitchState(UpdateProcedureState.ProcedurePatchInit);
2025-01-23 19:06:48 +08:00
return;
}
2025-04-28 19:45:45 +08:00
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
{
2025-04-28 19:45:45 +08:00
if (HttpHelper.Version != AppVersion.GameVersion)
2025-01-23 19:06:48 +08:00
{
2025-04-28 19:45:45 +08:00
Log.Warning($"Version inconsistency : {AppVersion.GameVersion}->{HttpHelper.Version} ");
2025-01-23 19:06:48 +08:00
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
2025-04-28 19:45:45 +08:00
UILoadTipWindow.ShowUILoadTip("VersionLow", () =>
{
Application.OpenURL(HttpHelper.AppDownloadUrl);
Application.Quit();
}).Forget();
2025-01-23 19:06:48 +08:00
#endif
return;
}
2025-04-28 19:45:45 +08:00
SwitchState(UpdateProcedureState.ProcedurePatchInit);
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
}