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; }); } }
public static PatcherElem DeSerialize(string txt) { PatcherElem ret = Json.Deserialize <PatcherElem>(txt); ret.CreatDic(); return(ret); }
void LoadLocalPatcher(System.Action <PatcherElem> onfinish) { string path = Application.dataPath + "/Patcher/ABs/" + GetABsPath(RuntimePlatform.WindowsPlayer) + "/Pather"; string content = File.ReadAllText(path); PatcherElem e = Json.Deserialize <PatcherElem>(content); if (null != onfinish) { onfinish(e); } }
List <PatcherElem.Elem> Compare(PatcherElem elem) { List <PatcherElem.Elem> ret = new List <Elem>(); foreach (var d in elem.mDic) { if (IsChange(d.Value)) { ret.Add(d.Value); } } return(ret); }
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(); } } ); } }