Last active
July 6, 2019 12:07
-
-
Save riveranb/14a8d87759fa54114858faa06c0baa68 to your computer and use it in GitHub Desktop.
C# check for internet connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // API doc for "WWW": https://docs.unity3d.com/ScriptReference/WWW.html | |
| public static IEnumerator InternetConnectTrying(Action<bool> action, float secs = 1) | |
| { | |
| WWW www = new WWW("https://www.google.com"); | |
| yield return www; | |
| yield return new WaitForSeconds(secs); | |
| if (www.error != null) | |
| { | |
| _cacheHttpError = www.error; | |
| } | |
| // action(bool): true means internec connection exists | |
| action.Invoke(www.responseHeaders != null && www.responseHeaders.Count > 0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment