Today encountered a problem, how to determine the current type of mobile game network connection, is WiFi or 234G?
Originally ready to write in Android plug-ins for unity to call, and later on the internet to browse the gods of the post, on the CSDN saw the use of networkreachability use, so their Andro perfect solution, the cock silk cherish kidney no love crazy, Hopefully someone can try to be available on iOS as well.
On the code: [Code]csharpcode:
Using unityengine;using System.collections;public class Test:monobehaviour { string s;//Use this for initialization void Start () { if (application.internetreachability = = networkreachability.reachableviacarrierdatanetwork) { s = "2g/3g/4g"; } else if (application.internetreachability = = networkreachability.reachablevialocalareanetwork) { s = "WiFi"; } Else if (application.internetreachability = = networkreachability.notreachable) { s = "Duan Wang"; } }//Update is called once per framevoid update () { } void Ongui () { Guilayout.label (s); }}
How unity determines the type of network connection