반응형

유니티 네트워크 체크 튜토리얼 Unity Network Check Tutorial - NetworkChecker.cs
이모티콘・01・고양이 마멋 친구들 - Google Play 앱
이모티콘・01・고양이 마멋 친구들: 무료 이모티콘, 회원가입 없이! 카톡, SNS로 감정 표현이 쉬워져요. 귀여움 가득, 대화창을 더 풍성하게!
play.google.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using UnityEngine; | |
public class NetworkChecker : MonoBehaviour | |
{ | |
public int check_interval; | |
int disconnect_count = 0; | |
private void Start() | |
{ | |
StartCoroutine(Co_check_network()); | |
} | |
IEnumerator Co_check_network() | |
{ | |
while (true) | |
{ | |
if (Application.internetReachability == NetworkReachability.NotReachable) | |
{ | |
disconnect_count++; | |
Check_three_strike(); | |
} | |
else | |
{ | |
// 네트워크 정상 | |
} | |
yield return new WaitForSeconds(check_interval); | |
} | |
} | |
public void Check_three_strike() | |
{ | |
if (disconnect_count >= 3) | |
{ | |
CallPopupManager.Instance.Call_popup( | |
"네트워크를 확인해 주세YO!\r\n게임을 종료합니다YO!.", | |
CommonPopupScript.POPUP_TYPE.POPUP_CONFIRM, | |
() => { Application.Quit(); }); | |
} | |
else | |
{ | |
CallPopupManager.Instance.Call_popup( | |
"네트워크를 확인해 주세YO!\r\n네트워크 에러 " + disconnect_count + "회", | |
CommonPopupScript.POPUP_TYPE.POPUP_CONFIRM, | |
() => { CallPopupManager.Instance.Close_popup_msg(); }); | |
} | |
} | |
} |

반응형