I try to download simple test data asynchronously:
using System.Collections;
using UnityEngine;
public class Download : MonoBehaviour
{
public string _url = "http://ipv4.download.thinkbroadband.com/10MB.zip";
WWW _www;
public void Start()
{
}
public void Update()
{
if (Input.GetMouseButtonDown(0))
{
StartCoroutine(DownloadAsync(_url));
}
if (_www == null)
{
return;
}
if (_www.isDone)
{
return;
}
Debug.Log("Update(" + _url + "), www.progress: " + _www.progress + ", www.bytesDownloaded: " + _www.bytesDownloaded);
}
public IEnumerator DownloadAsync(string url)
{
Debug.Log("DownloadAsync(" + url + ")");
_www = new WWW(url);
yield return _www;
Debug.Log("DownloadAsync(" + url + ") finished");
}
}
When clicking the mouse button, the entire game stops. I tested it in Unity Editor, Windows and Android.
Just what am I doing wrong?