Created
October 1, 2018 12:22
-
-
Save todorok1/6977a8f4d2b6b01023edd1ea20643c88 to your computer and use it in GitHub Desktop.
Unityでネットワークの状態を検知するスクリプト
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 System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class NetworkTest : MonoBehaviour { | |
public Text networkState; | |
void Start(){ | |
} | |
void Update(){ | |
CheckNetworkState(); | |
} | |
void CheckNetworkState(){ | |
// ネットワークの状態を確認する | |
if (Application.internetReachability == NetworkReachability.NotReachable){ | |
// ネットワークに接続されていない状態 | |
networkState.text = "ネットワークに未接続だっ! 通信環境をチェック!"; | |
} else { | |
// ネットワークに接続されている状態 | |
networkState.text = "ネットワークに接続されているよ!"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment