Unity判断网络连接类型

使用NetworkReachability判断手机游戏当前的网络连接类型,是wifi还是234G

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class Test : MonoBehaviour {
 5 
 6     string str;
 7     // Use this for initialization
 8     void Start () {
 9         if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
10         {
11             str = "2G/3G/4G";
12         }
13         else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
14         {
15             str = "wifi";
16         }
17         else if (Application.internetReachability == NetworkReachability.NotReachable)
18         {
19             str = "No Network";
20         }
21         
22 
23     }
24     
25     // Update is called once per frame
26     void Update () {
27         
28     }
29 
30     void OnGUI()
31     {
32         GUILayout.Label(str);
33     }
34 }
原文地址:https://www.cnblogs.com/zhangbaochong/p/4855709.html