This my code for checking for an internet connection on startup. It works on iOS, Android, Mac and Windows, but fails on WebGL. Ignoring the wierdness of checking for an internet connection in a WebGL build, I’m just curious why it fails ? It basically just checks that it can access google.com
UnityWebRequest www = new UnityWebRequest(internetCheckURL);
www.SendWebRequest();
float elapsedSecond = 0f;
while (!www.isDone)
{
elapsedSecond += internetCheckRate;
if (elapsedSecond >= 12.0f && www.downloadProgress <= 0.5)
{
break;
}
else
{
checkInternetMessage.text += ".";
yield return new WaitForSecondsRealtime(internetCheckRate);
}
}
if (!www.isDone || !string.IsNullOrEmpty(www.error))
{
Debug.LogError("No internet connection, retrying...");
StartCoroutine("CheckConnection");
yield break;
}
else if (www.isDone && string.IsNullOrEmpty(www.error))
{
Debug.Log("Internet Connection Detected");
checkInternetMessage.text = "Internet Connection Dectected.";
this.gameObject.SetActive(false);
}
}