[Unity] 유니티 인터넷 서비스 연결확인 관련
=======================
=======================
=======================
출처: docs.unity3d.com/ScriptReference/NetworkReachability.ReachableViaLocalAreaNetwork.html
NetworkReachability.ReachableViaLocalAreaNetwork
//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.";
}
}
}
=======================
=======================
=======================
출처: blog.daum.net/arkofna/18283247
Application.internetReachability
https://docs.unity3d.com/ScriptReference/NetworkReachability.ReachableViaLocalAreaNetwork.html
NetworkReachability
https://docs.unity3d.com/ScriptReference/NetworkReachability.html
Application.internetReachability 를 통해 인터넷 접속 상태를 확인할 수 있고,
NetworkReachability 를 통해 현재 어떤 통신 상태인지를 확인 할 수 있다.
void Update() { if (Application.internetReachability == NetworkReachability.NotReachable) { m_ReachabilityText = "Not Reachable."; } else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork) { m_ReachabilityText = "Reachable via carrier data network."; } else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork) { m_ReachabilityText = "Reachable via Local Area Network."; } } |
Not Reachable : 연결되어 있지 않음
Reachable via carrier data network : 4g 등, 통신사 데이터를 사용중
Reachable via Local Area Network : 로컬 데이터(wifi) 를 사용중
=======================
=======================
=======================
기타관련링크
- includecoding.tistory.com/12
- yeonhong.blogspot.com/2015/04/unity3d.html
=======================
=======================
=======================