void ExtractUpk()
 {
     ResetProgress(Status.Extract);
     StartThread(delegate {
         if (File.Exists(_upkPath))
         {
             FingerPrint.StartWriting(_bundleFolder);
             if (UPKExtra.ExtraUPK(_upkPath, _bundleFolder, _progress, true, delegate(string path, byte[] bytes) {
                 FingerPrint.AddItem(path, MiscUtils.GetMd5HashFromBytes(bytes), _bundleFolder);
             }))
             {
                 FingerPrint.Flush();
                 ChangeStatus(Status.Done);
                 File.Delete(_upkPath);
             }
             else
             {
                 Fail();
             }
         }
         else
         {
             ChangeStatus(Status.Request);
         }
     });
 }
        /// <summary>
        /// 释放
        /// </summary>
        public void Release()
        {
            this.progress = 0;
            UPKExtra.ExtraUPK(path + "/Enemy/EnemyDe.upk", path + "/Enemy", cp);
            print("释放完成");

            //this.StartCoroutine(WaitRelease());
        }
 void TestExtraUPK()
 {
     try
     {
         if (!Directory.Exists(ApplicationdataPath + "/OutPut/"))
         {
             Directory.CreateDirectory(ApplicationdataPath + "/OutPut/");
         }
         UPKExtra.ExtraUPK(ApplicationdataPath + "/Package_decompress.upk", ApplicationdataPath + "/OutPut/", m_CodeProgress);
     }
     catch (Exception ex)
     {
         Debug.Log(ex);
     }
 }
Exemple #4
0
 void ExtractUPK(UpdateVersion zipInfo)
 {
     try
     {
         string localPak = ResMng.GetUpdateTmpPath() + "/" + Guid.NewGuid().ToString() + ".pak";
         if (File.Exists(localPak))
         {
             File.Delete(localPak);
         }
         LZMAHelper.DeCompressFile(zipInfo.File.strLocalPath, localPak);
         UPKExtra.ExtraUPK(localPak, ResMng.GetResPath());
         AppInfo.SetAppVersion(zipInfo.VersionMax);
         UpdateHelper.CleanVersion();
         GameStart();
     }
     catch (Exception exp)
     {
         Log.WriteError(exp.Message + "|" + exp.StackTrace);
     }
 }
Exemple #5
0
    static void ImportFromGzip(string root, bool withEx, bool generateGz)
    {
        string[] oldFileMap     = null;
        var      configurations = ParseFrameworkConfiguration(Path.Combine(root, "framework/framework.conf"));

        if (configurations.Count == 0)
        {
            configurations = ParseFrameworkConfiguration(Path.Combine(root, "framework/FRAMEWORK.md"));
        }
        string oldVersion = "";

        if (configurations.ContainsKey("version"))
        {
            oldVersion = configurations["version"][0];
            var fileMapPath = Path.Combine(root, "framework/filemap/v" + oldVersion + ".txt");
            if (File.Exists(fileMapPath))
            {
                oldFileMap = File.ReadAllLines(fileMapPath);
            }
        }

        bool import = false;

        if (oldFileMap == null)
        {
            if (EditorUtility.DisplayDialog("⚠️ 警告!", "目标工程并非基于某一个玩创Lab框架版本, 是否确定要导入?", "确认", "取消"))
            {
                import = true;
            }
        }
        else
        {
            import = true;
        }

        if (import)
        {
            List <string> pathList = null;
            bool          success  = false;
            var           filePath = "";
            if (!generateGz)
            {
                filePath = EditorUtility.OpenFilePanel("选择gz文件", Path.Combine(root, "../"), "gz");
            }
            else
            {
                filePath = EditorFrameworkExport.ExportAsGzip(withEx);
            }
            if (!string.IsNullOrEmpty(filePath))
            {
                var upkPath = Path.Combine(root, "framework/output/" + Path.GetFileNameWithoutExtension(filePath));
                CheckCreateDirectory(upkPath);
                File.WriteAllBytes(upkPath, GZipUtil.UnZip(File.ReadAllBytes(filePath)));
                success = UPKExtra.ExtraUPK(upkPath, root, ref pathList);
                if (File.Exists(upkPath))
                {
                    File.Delete(upkPath);
                }
            }

            if (success)
            {
                if (oldFileMap != null && oldFileMap.Length > 0)
                {
                    foreach (var oldFile in oldFileMap)
                    {
                        if (!pathList.Contains(oldFile))
                        {
                            Debug.Log("Delete old version file: " + oldFile);
                            if (File.Exists(Path.Combine(root, oldFile)))
                            {
                                File.Delete(Path.Combine(root, oldFile));
                            }
                        }
                    }
                }
            }

            AssetDatabase.Refresh();
        }
    }
        IEnumerator WaitRelease()
        {
            yield return(new WaitForSeconds(1));

            UPKExtra.ExtraUPK(Application.dataPath + "/PackFolder/xmlDe.upk", Application.dataPath + "/PackFolder", cp);
        }