您的当前位置:首页正文

Untiy 检测网路是否连接

2024-11-28 来源:个人技术集锦
    private void CheckNetworkReachability()//检测网络状态
    {
        if (reachability == Application.internetReachability) return;
        reachability = Application.internetReachability;
        switch (reachability)
        {
            case NetworkReachability.NotReachable:
                Debug.Log("无线网络连接已断开");
                // 处理网络断开的情况
                break;
            case NetworkReachability.ReachableViaLocalAreaNetwork:
            case NetworkReachability.ReachableViaCarrierDataNetwork:
                Debug.Log("连接到热点网络");
                break;
        }
    }
显示全文