备份CatanBuilding瘦身独立工程
This commit is contained in:
47
Assets/Scripts/AOTScripts/PreBoot.cs
Normal file
47
Assets/Scripts/AOTScripts/PreBoot.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user