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 UnityEngine;
|
|
|
|
|
using YooAsset;
|
|
|
|
|
|
|
|
|
|
namespace Unity.Startup.Procedure
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取全局信息
|
|
|
|
|
/// </summary>
|
2025-04-28 19:45:45 +08:00
|
|
|
public sealed class ProcedureGetGlobalInfoState : 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();
|
|
|
|
|
if (GameApp.Resource.PlayMode == EPlayMode.EditorSimulateMode)
|
2025-01-23 19:06:48 +08:00
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
SwitchState(UpdateProcedureState.ProcedureGetAppVersionInfoState);
|
2025-01-23 19:06:48 +08:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 19:45:45 +08:00
|
|
|
if (GameApp.Resource.PlayMode == EPlayMode.OfflinePlayMode)
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//检查设备是否能够访问互联网
|
|
|
|
|
if (Application.internetReachability == NetworkReachability.NotReachable)
|
|
|
|
|
{
|
|
|
|
|
Log.Warning("The device is not connected to the network");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 19:45:45 +08:00
|
|
|
GetGlobalInfo();
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
2025-04-28 19:45:45 +08:00
|
|
|
|
|
|
|
|
private async void GetGlobalInfo()
|
2025-01-23 19:06:48 +08:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2025-04-28 19:45:45 +08:00
|
|
|
await HttpHelper.GetRemoteVersion();
|
|
|
|
|
SwitchState(UpdateProcedureState.ProcedureGetAppVersionInfoState);
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e.Message);
|
|
|
|
|
await UniTask.Delay(3000);
|
2025-04-28 19:45:45 +08:00
|
|
|
GetGlobalInfo();
|
2025-01-23 19:06:48 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-01-26 20:55:39 +08:00
|
|
|
}
|