示例#1
0
    IEnumerator WaitDownLoad()
    {
        WaitForSeconds waitForSeconds = new WaitForSeconds(0.2f);

        while (true)
        {
            bool isPause      = DownLoadManager.GetInstance().IsPause();
            bool isFailed     = DownLoadManager.GetInstance().IsFaied();
            long downLoadSize = DownLoadManager.GetInstance().GetDownLoadSize();
            long speed        = DownLoadManager.GetInstance().GetSpeed();
            if (isPause)
            {
                if (!isFailed)
                {
                    text_progress.text = "下载成功";
                    SetState(DownloadState.WaitStart);
                    UpdateText();
                    break;
                }
                else
                {
                    if (state != DownloadState.WaitContine)
                    {
                        text_progress.text = "下载中断,等待继续...";
                        SetState(DownloadState.WaitContine);
                    }
                }
            }
            else
            {
                text_progress.text = string.Format("下载中..{0}, 速度:{1}/s", FileUtils.ByteToString(downLoadSize), FileUtils.ByteToString(speed));
            }
            yield return(waitForSeconds);
        }

        yield return(null);
    }