List <FileInfo> GetAllDirectoriesFiles() { List <FileInfo> allDirectoriesFiles = new List <FileInfo>(); SqliteHelper sqlHelper = new SqliteHelper(); DataSet ds = sqlHelper.QueryBySQL("select dir from Directories"); foreach (DataRow dr in ds.Tables[0].Rows) { allDirectoriesFiles.AddRange(DirTools.GetAllFiles(dr[0].ToString())); } return(allDirectoriesFiles); }
public void ClearRes() { ResMap.Clear(); var lst = new List <Transform>(); foreach (Transform child in Content) { lst.Add(child); } for (int i = 0; i < lst.Count; i++) { Destroy(lst[i].gameObject); } DirTools.CleanUpDir(); }
/// <summary> /// 增加 /// </summary> /// <param name="model"></param> /// <returns></returns> public int addFirstLevelDir(FirstLevelDirModel model) { DirDbContext context = new DirDbContext(); if (model != null) { FirstLevel entity = new FirstLevel(); modelToEntity(model, ref entity); DirTools tools = new DirTools(); entity.afterContent = tools.afterContent; entity.beforContent = tools.beforContent; entity.activityFlag = 1; var result = context.firstLevels.Add(entity); } return(context.SaveChanges()); }
//仅从大图中裁剪出小图 public static void JustSplit(Texture2D bigTexture, Frame frame) { int sampleWidth = frame.size.width; int sampleHeight = frame.size.height; int destWidth = sampleWidth; int destHeight = sampleHeight; Texture2D destTexture = new Texture2D(destWidth, destHeight); //旋转时, 采样宽高调换 if (frame.isRotated) { sampleWidth = frame.size.height; sampleHeight = frame.size.width; } //起始位置(Y轴需变换,且受旋转影响)。 int startPosX = frame.startPos.x; int startPosY = bigTexture.height - (frame.startPos.y + sampleHeight); Color[] colors = bigTexture.GetPixels(startPosX, startPosY, sampleWidth, sampleHeight); //设置像素(将采样像素放到目标图中去) for (int w = 0; w < destWidth; w++) { for (int h = 0; h < destHeight; h++) { if (frame.isRotated) { //旋转时,目标图中的坐标(w, h),对应的采样区坐标为(h, sampleHeight-1-w) int index = (sampleHeight - 1 - w) * sampleWidth + h; destTexture.SetPixel(w, h, colors[index]); } else { //没有旋转时,目标图中的坐标(w, h),对应的采样区坐标为(w, h) int index = h * sampleWidth + w; destTexture.SetPixel(w, h, colors[index]); } } } destTexture.Apply(); byte[] bytes = destTexture.EncodeToPNG(); Save(DirTools.GetSplitedPNGDir(), frame.textureName, bytes); Texture2D.Destroy(destTexture); destTexture = null; }
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()); }
IEnumerator Unpacker(string plistFilePath, string pngFilePath) { DirTools.DeleteFolder(DirTools.GetRestoredPNGDir()); var loader = NRatel.TextureUnpacker.Loader.LookingForLoader(plistFilePath); if (loader != null) { var plist = loader.LoadPlist(plistFilePath); var bigTexture = loader.LoadTexture(pngFilePath, plist.metadata); int total = plist.frames.Count; int count = 0; foreach (var frame in plist.frames) { try { Core.Restore(bigTexture, frame); count += 1; } catch { } } } DirectoryInfo dir = new DirectoryInfo(DirTools.GetUnZipDir()); FileInfo[] finfo = dir.GetFiles(); for (int i = 0; i < finfo.Length; i++) { var file = finfo[i]; if (file.Name.IndexOf("plist") > -1 || file.Name.IndexOf("png") > -1) { } else { File.Copy(file.FullName, DirTools.GetRestoredPNGDir() + "/" + file.Name, true); } } ImportToResPanel(); yield return(null); }
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); } } }
protected override void OnInit(QFramework.IUIData uiData) { mData = uiData as UIResourcePanelData ?? new UIResourcePanelData(); // please add init code here var activity = mData.activityIndex; var id = mData.id; TextLabel.text = "ResArea-" + activity; var version = PlayerPrefs.GetString("Version"); gameObject.AddComponent <FileDragAndDrop>(); DirTools.ActivityIndex = activity; DirTools.Version = version; TypeEventSystem.Register <ResBlockNameChanged>(NameChanged); Export.onClick.AddListener(ExportRes); Clear.onClick.AddListener(ClearRes); God.onClick.AddListener(() => { UIMgr.OpenPanel("UIUploadPanel", UILevel.Common, new UIUploadPanelData() { ActivityIndex = activity, id = id }); }); TypeEventSystem.Register <RemoveBlock>((tmp) => { var md5 = tmp.MD5; ResMap.Remove(md5); string resDir = DirTools.GetTmpResDir(); string filepath = Path.Combine(resDir, md5 + tmp.Extension); if (File.Exists(filepath)) { File.Delete(filepath); } else { Debug.LogError("资源不存在!!!"); } }); TypeEventSystem.Register <SetBlockProperties>((tmp) => { var md5 = tmp.MD5; var properties = tmp.properties; var ResBlock = ResMap[md5]; ResBlock.GetComponent <ResBlockScript>().Properties = properties; }); TypeEventSystem.Register <ClearRescoursePanel>((tmp) => { ResMap.Clear(); var lst = new List <Transform>(); foreach (Transform child in Content) { lst.Add(child); } for (int i = 0; i < lst.Count; i++) { Destroy(lst[i].gameObject); } DirTools.DeleteFolder(DirTools.GetTmpResDir()); }); TypeEventSystem.Register <FilePathInfo>((file) => { if (ResMap.ContainsKey(file.MD5)) { return; } else if (file.Extension == ".zip") { MessageBoxV2.AddMessage("暂不支持拖入zip", 3); } else { var BlockImage = Instantiate(ResBlockPrefab, Content); BlockImage.GetComponent <ResBlockScript>().SetImage(file); DirTools.CopyDropFileToTmpResDir(file); ResMap.Add(file.MD5, BlockImage); } }); DirTools.CleanUpDir(); ResMap.Clear(); #if UNITY_EDITOR Invoke("Test", 3.0f); #endif }
IEnumerator BackupConfig(AttachmentsConfig config, string type) { var url = string.Format("http://gate-static.97kid.com/{0}", config.attachments.uri); UnityWebRequest webRequest = UnityWebRequest.Get(url); yield return(webRequest.SendWebRequest()); if (webRequest.isNetworkError) { Debug.Log(": Error: " + webRequest.error); } else { DateTime date = DateTime.Now; var dateStr = date.ToString("yyyyMMdd-HH时mm分ss秒"); var zipPath = DirTools.GetBackupDir() + "/" + dateStr + "." + config.attachments.ext_name; Debug.Log(zipPath); var data = webRequest.downloadHandler.data; File.WriteAllBytes(zipPath, data); if (type == "replace") { StartCoroutine(UploadConfig(config)); } else if (type == "restore") { DirTools.DeleteFolder(DirTools.GetUnZipDir()); ZipUtil.UnZipFile(zipPath, DirTools.GetUnZipDir()); StartCoroutine(Unpacker(DirTools.GetUnZipDir() + "/default.plist", DirTools.GetUnZipDir() + "/default.png")); } } }