Advertisement
Guest User

Unity3d WWW timeout

a guest
Nov 1st, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1.     private IEnumerator FetchUrl(string url)
  2.     {
  3.         print("Start fetching");
  4.  
  5.         WWW www = new WWW(url);
  6.  
  7.         for (int i = 0; i < TimeoutInSeconds; i++)
  8.         {
  9.             yield return new WaitForSeconds(1);
  10.             if (www.isDone) break;
  11.         }
  12.  
  13.         if (!www.isDone)
  14.         {
  15.             print("Timeout expired");
  16.             www.Dispose();
  17.             yield break;
  18.         }
  19.  
  20.         if (!string.IsNullOrEmpty(www.error))
  21.         {
  22.             Debug.LogError(www.error);
  23.             yield break;
  24.         }
  25.  
  26.         print("Url fetched: " + www.text);
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement