コード例 #1
0
        /// <summary>
        /// 组合打包文件
        /// </summary>
        /// <returns></returns>
        private IEnumerator PitchFile()
        {
            this.m_updatPhase = UpdatePhase.PitchFile;

            string fileName  = "Temp/" + KTConfigs.kSrcName;
            string deltaName = "Temp/" + KTConfigs.kDeltaName;

            Debug.Log("组合补丁文件");
            Directory.SetCurrentDirectory(KTPathHelper.DataPath);
            OctodiffUtil.ExecutePitch(fileName, deltaName, KTConfigs.kSrcName);

            //把新的src.zip文件拷贝到persistentDataPath/Temp目录下,覆盖掉原来的src.zip
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            if (File.Exists(KTConfigs.kSrcName))
            {
                File.Move(KTConfigs.kSrcName, fileName);
            }

            //删掉除Temp目录之外的所有旧资源,目录直接删掉,文件不需要删,会直接覆盖
            Directory.Delete(KTPathHelper.DataPath + "BuildRes", true);
            Directory.Delete(KTPathHelper.DataPath + "lua", true);
            Directory.SetCurrentDirectory(Application.dataPath.Replace("/Assets", ""));

            Debug.Log("解压src.zip");
            this.m_updatPhase = UpdatePhase.UnZipFile;
            ZipTool.unZipFile(KTPathHelper.DataPath + fileName, KTPathHelper.DataPath);//需要时间
            yield return(UpdateComplete());
        }
コード例 #2
0
        /// <summary>
        /// 第一次运行前,在编辑器模式下,需要把src.zip和files文件从NewVersion目录手动拷贝到streamingAssetsPath目录中
        /// 第一次运行游戏,增量更新模式,把资源从streamingAssetsPath目录拷贝到Application.persistentDataPath目录
        /// 首先要把src.zip拷贝到persistentDataPath/Temp目录下
        /// 再把src.zip解压到Application.persistentDataPath下
        /// </summary>
        /// <returns></returns>
        private IEnumerator DeltaExtractResource()
        {
            this.m_updatPhase = UpdatePhase.DeltaExtractFile;
            //拷贝files.txt到persistentDataPath目录
            string srcPath = KTPathHelper.AppContentPath(); //游戏包资源释放和加载目录
            string dstPath = KTPathHelper.DataPath;         //发布后的游戏数据存储目录

            if (Directory.Exists(dstPath))
            {
                Directory.Delete(dstPath, true);
            }

            Directory.CreateDirectory(dstPath);

            string infile  = srcPath + "files.txt";
            string outfile = dstPath + "files.txt";

            yield return(CopyFile(infile, outfile));

            this.m_updatPhase = UpdatePhase.DeltaExtractSrc;
            if (!Directory.Exists(dstPath + "Temp"))
            {
                Directory.CreateDirectory(dstPath + "Temp");
            }

            //拷贝src.zip到persistentDataPath目录
            infile  = srcPath + KTConfigs.kDeltaName;
            outfile = dstPath + "Temp/" + KTConfigs.kDeltaName;
            yield return(CopyFile(infile, outfile));

            Debug.Log("解压" + KTConfigs.kDeltaName);
            ZipTool.unZipFile(outfile, dstPath);//同步操作 需要时间
            //if (ZipTool.inputStream.Available > 0)
            //    yield return new WaitForEndOfFrame();
            Debug.Log("解包完成!!!");
            yield return(DeltaUpdateResource());
        }