I'm trying to download something through WWW class.When I'm connected to internet, there is no problem. But when I'm not connected , In editor, it returns WWW.error , but in standalone it remains at (yield www).
IEnumerator checkConniction()
{
yield return www;
if(www.error != null)
{
print("faild to connect to internet, trying after 2 seconds.");
yield return new WaitForSeconds(2);// trying again after 2 sec
StartCoroutine(checkConniction());
}else
{
print("connected to internet");
// do somthing, play sound effect for example
yield return new WaitForSeconds(5);// recheck if the internet still exists after 5 sec
StartCoroutine(checkConniction());
}
}
But this is too simplistic and very problematic if you can’t afford to keep your whole application on hold for the response. Using async calls as in here, is much better.