48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
[DefaultExecutionOrder(2)]
|
|
public class PreBoot : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField]
|
|
private SimpleDialog reconnectDialog;
|
|
|
|
private bool HasNetwork => Application.internetReachability != NetworkReachability.NotReachable;
|
|
|
|
private void Start()
|
|
{
|
|
BetterStreamingAssets.Initialize();
|
|
StartCoroutine(CheckNetwork());
|
|
}
|
|
|
|
private void ShowRetryDialog()
|
|
{
|
|
reconnectDialog.Config(new SimpleDialog.Context()
|
|
{
|
|
message = Boostrapi18n.Instance.GetText("subtitle_networkfailed"),
|
|
message2 = Boostrapi18n.Instance.GetText("content_networkfailed"),
|
|
okAction = () => StartCoroutine(CheckNetwork()),
|
|
});
|
|
}
|
|
|
|
|
|
private IEnumerator CheckNetwork()
|
|
{
|
|
yield return new WaitForSeconds(0.3f);
|
|
if(!HasNetwork)
|
|
{
|
|
ShowRetryDialog();
|
|
}
|
|
else
|
|
{
|
|
GEvent.Init();
|
|
SceneManager.LoadScene("BoostrapScene");
|
|
}
|
|
}
|
|
|
|
}
|