Advertisement
ElectricJesus

Unity internet checker

Aug 30th, 2015
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  1.     public IEnumerator CheckInternetConnection(Action<bool> action){
  2.  
  3.         bool isConnected = false;
  4.  
  5.         WWW www = new WWW("Address you want to ping");
  6.         yield return www;
  7.  
  8.         if (www.error != null) {
  9.             isConnected = false;
  10.         } else {
  11.             if (www.text.Contains("Content")) {
  12.                 isConnected = true;
  13.             } else {
  14.                 isConnected = false;
  15.             }
  16.         }
  17.  
  18.         if (action != null) {
  19.             action (isConnected);
  20.         }
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement