版本:Unity 6 (6000.0)
语言英语
  • C#

NetworkReachability.NotReachable

建议更改

成功!

感謝您幫助我們改善 Unity 文件的品質。儘管我們不能接受所有建議,但我們會閱讀每個使用者建議的更改並在適用的情況下進行更新。

關閉

提交失敗

由於某些原因,您建議的更改無法提交。請在幾分鐘後<a>重新嘗試</a>。並感謝您花時間幫助我們改善 Unity 文件的品質。

關閉

取消

說明

無法訪問網路。

//Attach this script to a GameObject
//This script checks the device’s ability to reach the internet and outputs it to the console window

using UnityEngine;

public class Example : MonoBehaviour { string m_ReachabilityText;

void Update() { //Output the network reachability to the console window Debug.Log("Internet : " + m_ReachabilityText); //Check if the device cannot reach the internet if (Application.internetReachability == NetworkReachability.NotReachable) { //Change the Text m_ReachabilityText = "Not Reachable."; } //Check if the device can reach the internet via a carrier data network else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork) { m_ReachabilityText = "Reachable via carrier data network."; } //Check if the device can reach the internet via a LAN else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { m_ReachabilityText = "Reachable via Local Area Network."; } } }