Exemplo n.º 1
0
    public IEnumerator Download(string name)
    {
        string url = System.IO.Path.Combine(FloorTextureManager.downloadNewUrl, FloorTextureManager.GetFileName(name));

        // Debug.Log("  down load    == "  + name  );
        WWW www = new WWW(url);

        //Debug.Log(url);
        //定义www为WWW类型并且等于所下载下来的WWW中内容。
        while (!www.isDone)
        {
            Progress(www);
            yield return(1);
        }
        //返回所下载的www的值
        if (string.IsNullOrEmpty(www.error))
        {
            FloorTextureManager.SaveTexture(name, www.texture.EncodeToPNG());
            if (EndDownload != null)
            {
                EndDownload(www.texture, name);
            }
        }
        else
        {
            Debug.Log("DownloadError=>" + www.error + "   name  == " + name);
            if (DownloadError != null)
            {
                DownloadError(name);
            }
        }
    }
Exemplo n.º 2
0
    // 预下载
    public IEnumerator PreDownload(string nextName)
    {
        if (Core.Data.usrManager.UserConfig.cartoon == 1) //自动下载
        {
            if (!FloorTextureManager.CheckExist(nextName))
            {
                //   Debug.Log("   in preDownload   ======   " + nextName);
                string url = System.IO.Path.Combine(FloorTextureManager.downloadNewUrl, FloorTextureManager.GetFileName(nextName));
                WWW    www = new WWW(url);
                yield return(www);

                if (string.IsNullOrEmpty(www.error))
                {
                    FloorTextureManager.SaveTexture(nextName, www.texture.EncodeToPNG());
                }
                else
                {
                    Debug.LogError(" DownloadError  => " + nextName);
                }
            }
        }
    }