示例#1
0
    IEnumerator LoadBeatch(LoadBeatchStep current)
    {
        Frame.Executer.SetProgressText(current.name);
        yield return(null);

        LoadBeatchStep beatch    = (LoadBeatchStep)current;
        var            urlFiles  = beatch.getURLs();
        var            len       = urlFiles.Count;
        int            totalSize = 0;

        urlFiles.ForEach((item) => totalSize += item.size);
        int curSize = 0;

        for (int i = 0; i < len; ++i)
        {
            string url  = urlFiles[i].url;
            int    size = urlFiles[i].size;
            Debug.Log(url);
            WWW www = new WWW(url);
            while (!www.isDone)
            {
                Frame.Executer.SetProgress(curSize + (int)(size * www.progress), totalSize);
                Thread.Sleep(1);
                yield return(null);
            }
            if (!string.IsNullOrEmpty(www.error))
            {
                Error(www.error, current.errorCode);
                yield break;
            }
            curSize += www.bytesDownloaded;
            beatch.loadDelegate(www);
            www.Dispose();

            if (current.onEnd != null)
            {
                current.onEnd();
            }

            if (current.exit != null && current.exit())
            {
                Error(current.name, current.errorCode);
                yield break;
            }
            yield return(null);
        }
    }