public void ExportRes() { Debug.Log("导出资源"); Dictionary <string, Dictionary <string, string> > TotalProperties = new Dictionary <string, Dictionary <string, string> >(); var list = GetResTransform(); foreach (var tran in list) { var BlockImageScript = tran.GetComponent <ResBlockScript>(); var properties = BlockImageScript.Properties; try { TotalProperties.Add(properties["Name"], properties); } catch (Exception ex) { Debug.Log(ex); MessageBoxV2.AddMessage("导出失败:重复的资源名称"); return; } } var dataAsJson = QF.SerializeHelper.ToJson(TotalProperties); File.WriteAllText(DirTools.GetTmpOutPutDir() + "/ResConfig.json", dataAsJson); TexturePackage(); Compress(); GenerateCode(); System.Diagnostics.Process.Start(DirTools.GetBasePathDir()); }
public void Compress() { var isOn = ToggleCompress.isOn; if (isOn) { ZipUtil.ZipDirectory(DirTools.GetTmpOutPutDir(), DirTools.GetOutPutDir() + "/ResConfig.zip", false); } }
public Dictionary <string, string> GetDescription() { var description_dict = new Dictionary <string, string>(); var dict = getResConfig(DirTools.GetTmpOutPutDir()); foreach (KeyValuePair <string, Dictionary <string, string> > kv in dict) { var properties = kv.Value; string description; properties.TryGetValue("Description", out description); if (description == null || description == "") { Debug.Log("properties:" + properties["Name"]); } else { description_dict.Add(kv.Key, description); } } Debug.Log(description_dict.ToString()); return(description_dict); }
public void TexturePackage() { var resDir = DirTools.GetTmpResDir(); string[] files = System.IO.Directory.GetFiles(resDir); var outputDir = DirTools.GetTmpOutPutDir(); var isOn = ToggleTexturePackage.isOn; if (isOn) { string name = "default"; var command = Application.streamingAssetsPath + "/bin/TexturePacker.exe"; var argu = string.Format(@"{0} --sheet {1}/{2}.png --data {1}/{2}.plist --allow-free-size --no-trim --max-size 2048 --format cocos2d", resDir, outputDir, name); Utils.processCommand(command, argu); // Copy the files and overwrite destination files if they already exist. foreach (string s in files) { // Use static Path methods to extract only the file name from the path. if (System.IO.Path.GetExtension(s) != ".png") { var fileName = System.IO.Path.GetFileName(s); var destFile = System.IO.Path.Combine(outputDir, fileName); System.IO.File.Copy(s, destFile, true); } } } else { foreach (string s in files) { var fileName = System.IO.Path.GetFileName(s); var destFile = System.IO.Path.Combine(outputDir, fileName); System.IO.File.Copy(s, destFile, true); } } }