Skip to content

Instantly share code, notes, and snippets.

@todorok1
Created October 1, 2018 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todorok1/6977a8f4d2b6b01023edd1ea20643c88 to your computer and use it in GitHub Desktop.
Save todorok1/6977a8f4d2b6b01023edd1ea20643c88 to your computer and use it in GitHub Desktop.
Unityでネットワークの状態を検知するスクリプト
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