コード例 #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
        protected override void OnInit(QFramework.IUIData uiData)
        {
            mData = uiData as UIPanelData ?? new UIPanelData();
            // please add init code here
            isTexturePackage.isOn = PlayerPrefs.GetInt("isTexturePackage", 1) > 0;
            ResourceTag.Default   = isTexturePackage.isOn ? ResourceTag.TexturePackage : ResourceTag.None;
            isTexturePackage.onValueChanged.AddListener((ret) =>
            {
                ResourceTag.Default = isTexturePackage.isOn ? ResourceTag.TexturePackage : ResourceTag.None;
                PlayerPrefs.SetInt("isTexturePackage", isTexturePackage.isOn ? 1:-1);
            });
            TypeEventRegister();
            UploadButton.onClick.AddListener(() =>
            {
                transform.GetComponent <Backends>().Upload(_template);
                GenerateZip();
            });
            DownloadButton.onClick.AddListener(() =>
            {
                transform.GetComponent <Backends>().Download(_template);
            });
            ClearAllResButton.onClick.AddListener(() =>
            {
                int childCount = ScrollViewContent.childCount;
                for (int i = 0; i < childCount; i++)
                {
                    Destroy(ScrollViewContent.GetChild(i).gameObject);
                }
                DirTools.ClearTempPath();
                DirTools.ClearOutputPath();
            });

            var LoginPanel = transform.Find("LoginPanel");

            if (LoginPanel)
            {
                LoginPanel.gameObject.SetActive(true);
            }

            // StartCoroutine(VersionCheck());
        }