Пример #1
0
        private bool GenerateZip()
        {
            Debug.Log("导出");
            DirTools.ClearOutputPath();
            List <ResourceInfo> TotalInfo = new List <ResourceInfo>();

            foreach (Transform child in ScrollViewContent)
            {
                var info = child.GetComponent <ResourceItem>().ResInfo;
                TotalInfo.Add(info);
            }

            var texturePackageComponent = transform.GetComponent <TexturePackageComponent>();
            var result = texturePackageComponent.TexturePackage(TotalInfo);

            if (result.Ret == false)
            {
                ShowErrorTips(result.Reason);
                return(false);
            }
            else
            {
                var resTexturePackage     = (TexturePackageDone)result;
                var generateJsonComponent = transform.GetComponent <GenerateJsonComponent>();
                var result1 = generateJsonComponent.SerializeToJson(TotalInfo, resTexturePackage.PlistsName);
                if (result1.Ret == false)
                {
                    ShowErrorTips(result1.Reason);
                    return(false);
                }
                var resJson    = (GenerateJsonDone)result1;
                var NonePath   = DirTools.GetOutputNonePath();
                var PlistPath  = DirTools.GetOutputPlistPath();
                var CsbPath    = DirTools.GetOutputCsbPath();
                var OutPutPath = DirTools.GetOutputPath();
                var filesNone  = TotalInfo.Where((info) => { return(info.Tag == ResourceTag.None); }).ForEach((info) =>
                {
                    File.Copy(info.FileFullName, NonePath + "/" + info.FileName);
                });
                var filesCsb = TotalInfo.Where((info) => { return(info.Tag == ResourceTag.CocosStudio); }).ForEach((info) =>
                {
                    File.Copy(info.FileFullName, CsbPath + "/" + info.FileName);
                });
                resTexturePackage.Files.ForEach((path) =>
                {
                    var fileName = System.IO.Path.GetFileName(path);
                    File.Copy(path, PlistPath + "/" + fileName);
                });
                resJson.Files.ForEach((path) =>
                {
                    var fileName = System.IO.Path.GetFileName(path);
                    File.Copy(path, OutPutPath + "/" + fileName);
                });
                ZipUtil.ZipDirectory(DirTools.GetOutputPath(), DirTools.GetBasePath() + "/res.zip");
                return(true);
            }
        }
Пример #2
0
        public async void Export()
        {
            var ret = GenerateZip();

            if (ret)
            {
                System.Diagnostics.Process.Start(DirTools.GetBasePath());
            }
        }