Beispiel #1
0
    IEnumerator DoDownload(DownloadTask task)
    {
        string url = task.url;

        Debug.Log("[WWW-Download:] " + url);
        _mPubliser.NotifyLoadingName(url);
        _mRequestList.Remove(url);

        int cacheVersion = task.cacheVersion;

        if (cacheVersion >= 0)
        {
            task.www = WWW.LoadFromCacheOrDownload(url, cacheVersion);
        }
        else
        {
            task.www = new WWW(url);
        }

        _mDownLoadList.Add(url, task);

        if (task.www.isDone)
        {
            Debug.Log("[WWW-Load from cache:] " + url);
            _mLoadedList.Add(url, task);
        }
        else
        {
            while (!task.www.isDone)
            {
                Debug.Log("[WWW-Loading:] " + url + " " + task.www.progress);
                _mPubliser.NotifyProgress(url, task.www.progress);
                yield return(0);
            }

            if (!string.IsNullOrEmpty(task.www.error))
            {
                Debug.Log("[WWW-Error:] " + task.www.error);
            }
            else
            {
                Debug.Log("[WWW-Loaded:] " + url);
                _mLoadedList.Add(url, task);
            }
        }

        _mPubliser.NotifyComplete(url, task.www.error);
        _mDownLoadList.Remove(url);

        // Call DoSomething
        task.DoEventDelegate();

        yield break;
    }