美文网首页unity3D技术分享Unity教程合集Unity基础入门分享
unity3d检测网络是wifi连接还是数据连接或者已断开连接

unity3d检测网络是wifi连接还是数据连接或者已断开连接

作者: 好怕怕 | 来源:发表于2017-04-21 15:32 被阅读309次
using UnityEngine;
public class NwtWork : MonoBehaviour
{
    private float time = 0f;
    void Update()
    {
        time += Time.deltaTime * 1;
        if (time >= 1)
        {
            time = 0f;
            switch (Application.internetReachability)
            {
                case NetworkReachability.NotReachable:
                    Debug.LogError("网络断开");
                    break;
                case NetworkReachability.ReachableViaLocalAreaNetwork:
                    Debug.LogError("WIFI");
                    break;
                case NetworkReachability.ReachableViaCarrierDataNetwork:
                    Debug.LogError("4G/3G");
                    break;
            }
        }
    }
}

相关文章

网友评论

    本文标题:unity3d检测网络是wifi连接还是数据连接或者已断开连接

    本文链接:https://www.haomeiwen.com/subject/pdvdzttx.html