public override void Init(params object[] args) { mLoadPercent = new LoadPercent(); mLastLoadMode = mCurLoadMode; mCurLoadMode = (LoadMode)args[0]; EventManager.instance.Send(LoadSceneManager.LoadEvent, LoadSceneManager.LoadType.LT_Begin, mCurLoadMode); mCurLoadMode.PlayLoad(LoadSceneManager.LoadType.LT_Begin); BaseLoad bl = null; string planeTypeName = mCurLoadMode.PlaneName; planeTypeName = string.IsNullOrEmpty(planeTypeName)?ResConfig.FNORMALLOAD: planeTypeName; bl = FEngineManager.PoolObject <BaseLoad>(planeTypeName, this.gameObject); bl.GetComponent <RectTransform>().NormalRectTransform(); bl.IsPool = bl.InitOpen(this, mCurLoadMode); StartCoroutine(PlayFun(mCurLoadMode.ToSceneName, bl)); }
public LoadPercent CreateBranch(float pre, bool abs = true) { LoadPercent lp = new LoadPercent(); if (abs) { lp.mRelativePer = pre; } else { var pro = GetPercent(); lp.mRelativePer = (1 - pro.pre) * pre; } lp.mParent = this; return(lp); }
public ZipThreadData ThreadUnZip(string ZipFile, string TargetDirectory, string Password, LoadPercent loadPercent = null, bool OverWrite = true)//解压Zip { return(FZipTool.ThreadUnZip(ZipFile, TargetDirectory, Password, loadPercent, OverWrite)); }
public static void UnZip(string ZipFile, string TargetDirectory, string Password, LoadPercent loadPercent = null, bool OverWrite = true) { ZipConstants.DefaultCodePage = System.Text.Encoding.UTF8.CodePage; if (loadPercent == null) { loadPercent = new LoadPercent(); } loadPercent.SetKD("Decompression"); //如果解压到的目录不存在,则报错 FEPath.CreateDirectory(TargetDirectory); //目录结尾 if (!TargetDirectory.EndsWith("/")) { TargetDirectory = TargetDirectory + "/"; } FileStream stream = File.OpenRead(ZipFile); using (ZipInputStream zipfiles = new ZipInputStream(stream)) { zipfiles.Password = Password; ZipEntry theEntry; bool isShowPro = true; lock (loadPercent) { loadPercent.SetTimece(stream.Length); isShowPro = stream.Length > 1024 * 1024 * 5; } while ((theEntry = zipfiles.GetNextEntry()) != null) { string directoryName = ""; string pathToZip = ""; pathToZip = theEntry.Name; long compressedSize = theEntry.CompressedSize; if (pathToZip != "") { directoryName = FEPath.GetDirectoryName(pathToZip) + "/"; } string fileName = FEPath.GetFileName(pathToZip); FEPath.CreateDirectory(TargetDirectory + directoryName); if (fileName != "") { if ((File.Exists(TargetDirectory + directoryName + fileName) && OverWrite) || (!File.Exists(TargetDirectory + directoryName + fileName))) { using (FileStream streamWriter = File.Create(TargetDirectory + directoryName + fileName)) { int size = 2048; byte[] data = new byte[2048]; while (true) { size = zipfiles.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { lock (loadPercent) { var dataPro = loadPercent.GetPercent(); if (isShowPro) { loadPercent.GoOn((dataPro.pre * 100).ToString("0") + "%", compressedSize); } } break; } } streamWriter.Close(); } } else { lock (loadPercent) { var dataPro = loadPercent.GetPercent(); if (isShowPro) { loadPercent.GoOn((dataPro.pre * 100).ToString("0") + "%", compressedSize); } } } } } zipfiles.Close(); } stream.Close(); stream.Dispose(); lock (loadPercent) { loadPercent.Over(""); } }
public static ZipThreadData ThreadUnZip(string ZipFile, string TargetDirectory, string Password, LoadPercent loadPercent = null, bool OverWrite = true) { IsEnter = true; ZipThreadData ztd = new ZipThreadData(); ztd.ZipFile = ZipFile; ztd.IsZipIng = true; ztd.TargetDirectory = TargetDirectory; ztd.Password = Password; ztd.loadPercent = loadPercent; ztd.OverWrite = OverWrite; Timer_Thread.SetTimer((t, r) => { try { UnZip(ztd.ZipFile, ztd.TargetDirectory, ztd.Password, ztd.loadPercent, ztd.OverWrite); ztd.IsZipIng = false; } catch (System.Exception e) { ztd.error = "解压线程出现错误:" + e.ToString(); ztd.loadPercent.Over("", 1, ztd.error); ztd.IsZipIng = false; } return(-1); }, 0, null); return(ztd); }