Exemplo n.º 1
0
    public void Begin(int p, string url)
    {
        mVersion = p;
        int v = PlayerPrefs.GetInt("UnPackVersion", 0);

        if (mVersion > v)
        {
            TextAsset ta = (TextAsset)Resources.Load("Game");

            using (MemoryStream ms = new MemoryStream(ta.bytes))
            {
                ZipStorer zip = ZipStorer.Open(ms, FileAccess.Read);
                List <ZipStorer.ZipFileEntry> dir = zip.ReadCentralDir();
                foreach (ZipStorer.ZipFileEntry entry in dir)
                {
                    string outPath = Application.persistentDataPath + "/" + entry.FilenameInZip;
                    zip.ExtractFile(entry, outPath);
                }
                zip.Close();
            }
            PlayerPrefs.SetInt("UnPackVersion", mVersion);
            GameObject dGo = new GameObject("Downloader");
            mDownloader = dGo.AddComponent <PatcherDownloader>();
            mDownloader.BeginDownload(url, delegate(PatcherElem e)
            {
                mCurElems = e;
                GameObject.Destroy(dGo);
                mDownloader = null;
            });
        }
    }
Exemplo n.º 2
0
 public void BeingDownload(string url, bool debug, System.Action onfinish, System.Action <string> onerror)
 {
     mOnError = onerror;
     if (!debug)
     {
         GameObject dGo = new GameObject("Downloader");
         mDownloader = dGo.AddComponent <PatcherDownloader>();
         mDownloader.BeginDownload(url, delegate(PatcherElem e)
         {
             mCurElems        = e;
             mCurElems.mDebug = false;
             if (null != dGo)
             {
                 GameObject.Destroy(dGo);
             }
             mDownloader = null;
             if (null != onfinish)
             {
                 onfinish();
             }
         }, onerror);
     }
     else
     {
         LoadLocalPatcher(delegate(PatcherElem e)
         {
             mCurElems        = e;
             mCurElems.mDebug = true;
             mDownloader      = null;
             if (null != onfinish)
             {
                 onfinish();
             }
         }
                          );
     }
 }