码迷,mamicode.com
首页 > 编程语言 > 详细

Unity判断网络连接类型

时间:2015-10-05 15:35:13      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:

使用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 }

 

Unity判断网络连接类型

标签:

原文地址:http://www.cnblogs.com/zhangbaochong/p/4855709.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!