Unity3d Detect NetState
1 public static bool HasConnection() 2 { 3 System.Net.WebClient client; 4 System.IO.Stream stream; 5 try 6 { 7 using (client = new System.Net.WebClient()) 8 9 using (stream = client.OpenRead(GameUrl.BaseUrl)) 10 { 11 return client.ResponseHeaders != null && client.ResponseHeaders.Count > 0; 12 } 13 14 } 15 catch (Exception e) 16 { 17 return false; 18 } 19 }