使用NetworkReachability判断手机游戏当前的网络连接类型,是wifi还是234G
using UnityEngine;
using System.Collections; public class Test : MonoBehaviour { string str;
// Use this for initialization
void Start () {
if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
{
str = "2G/3G/4G";
}
else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
{
str = "wifi";
}
else if (Application.internetReachability == NetworkReachability.NotReachable)
{
str = "No Network";
} } // Update is called once per frame
void Update () { } void OnGUI()
{
GUILayout.Label(str);
}
}