IEnumerator OnExtractResource() { if (!Directory.Exists(m_dataPath)) { Directory.CreateDirectory(m_dataPath); } string resPath = Util.AppContentPath(); //游戏包资源目录 string infileTemp = m_dataPath + m_filesName; string infile = resPath + m_filesName; if (Application.platform == RuntimePlatform.Android) { WWW www = new WWW(infile); yield return(www); if (www.isDone) { File.WriteAllBytes(infileTemp, www.bytes); //保存files文件 } yield return(0); } else { File.Copy(infile, infileTemp, true); } yield return(new WaitForEndOfFrame()); //释放所有文件到数据目录 string[] files = File.ReadAllLines(infileTemp); string[] fs = null; string outfileTemp = ""; int unzipCount = 0; foreach (var file in files) { fs = file.Split('|'); infileTemp = resPath + fs[0]; // outfileTemp = m_dataPath + fs[0]; string dir = Path.GetDirectoryName(outfileTemp); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (Application.platform == RuntimePlatform.Android) { WWW www = new WWW(infileTemp); yield return(www); if (www.isDone) { File.WriteAllBytes(outfileTemp, www.bytes); unzipCount++; yield return(0); } } else { File.Copy(infileTemp, outfileTemp, true); unzipCount++; } if (outfileTemp.EndsWith(AppConst.ZipName)) { if (outfileTemp.IndexOf("lua/") > 0) { if (!Directory.Exists(m_dataPath + "lua")) { Directory.CreateDirectory(m_dataPath + "lua"); } Util.DecompressFileFastZip(outfileTemp, m_dataPath + "lua"); } else { Util.DecompressFileFastZip(outfileTemp, m_dataPath); } m_view.UpdateProgress(unzipCount, files.Length); File.Delete(outfileTemp); } yield return(new WaitForEndOfFrame()); } m_view.UpdateProgress(files.Length, files.Length); string versionsInfile = resPath + "versions.txt"; string versionsOutfile = m_dataPath + "versions.txt"; if (File.Exists(versionsOutfile)) { File.Delete(versionsOutfile); } if (Application.platform == RuntimePlatform.Android) { WWW www = new WWW(versionsInfile); yield return(www); if (www.isDone) { File.WriteAllBytes(versionsOutfile, www.bytes); } yield return(0); } else { File.Copy(versionsInfile, versionsOutfile, true); } yield return(new WaitForEndOfFrame()); StartCoroutine(OnUpdateResource()); }