| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781 | 
							- using System;
 
- using System.Collections.Generic;
 
- using System.Diagnostics;
 
- using System.IO;
 
- using System.Net;
 
- using System.Reflection;
 
- using System.Security.Cryptography;
 
- using System.Text;
 
- using UnityEditor;
 
- using UnityEditor.U2D;
 
- using UnityEngine;
 
- using UnityEngine.U2D;
 
- using UnityEngine.UI.PackgTool;
 
- using Debug = UnityEngine.Debug;
 
- using Object = System.Object;
 
- namespace UnityEditor.UI
 
- {
 
-     public class UGUIPackgToolWindow : EditorWindow
 
-     {
 
-         public class SVNInfo
 
-         {
 
-             public int yb;
 
-             public int bb;
 
-             public string url;
 
-         }
 
-         private Vector2 pos = Vector2.zero;
 
-         private static string dbPath;
 
-         public string findName;
 
-         private static string packgPath;
 
-         int bbh1 = 0;
 
-         int bbh2 = 0;
 
-         [UnityEditor.MenuItem("UI/图集")]
 
-         public static void Open()
 
-         {
 
-             packgPath = Application.dataPath.Replace("Assets", "UGUIPack/");
 
-             if (!System.IO.Directory.Exists(packgPath))
 
-             {
 
-                 Directory.CreateDirectory(packgPath);
 
-             }
 
-             dbPath = packgPath + "uguiconfig.db";
 
-             UGUIPackgToolWindow uguiPackgToolWindow = UGUIPackgToolWindow.GetWindow<UGUIPackgToolWindow>();
 
-             uguiPackgToolWindow.Show();
 
-         }
 
-         public void SetSVNInfo()
 
-         {
 
-             SVNInfo svnInfo = BanBenXinXing($"info {UGUICacheInfo.uguiPackDB.uiPath2}");
 
-             if (!string.IsNullOrEmpty(svnInfo.url))
 
-             {
 
-                 SVNInfo svnInfo2 = BanBenXinXing($"info {svnInfo.url}");
 
-                 bbh1 = svnInfo2.bb;
 
-                 bbh2 = svnInfo.bb;
 
-             }
 
-         }
 
-         public SVNInfo BanBenXinXing(string par)
 
-         {
 
-             if (!string.IsNullOrEmpty(UGUICacheInfo.uguiPackDB.uiPath2))
 
-             {
 
-                 SVNInfo svnInfo = new SVNInfo();
 
-                 List<string> info = Proce(par);
 
-                 if (info.Count <= 0)
 
-                 {
 
-                     return svnInfo;
 
-                 }
 
-                 for (int i = 0; i < info.Count; i++)
 
-                 {
 
-                     int index = info[i].IndexOf(":");
 
-                     if (index <= 0)
 
-                     {
 
-                         continue;
 
-                     }
 
-                     string key = info[i].Substring(0, index);
 
-                     string value = info[i].Substring(index + 1);
 
-                     if (key.Equals("Revision"))
 
-                     {
 
-                         string v1 = value.Replace(" ", "");
 
-                         svnInfo.yb = int.Parse(v1);
 
-                     }
 
-                     if (key.Equals("Last Changed Rev"))
 
-                     {
 
-                         string v1 = value.Replace(" ", "");
 
-                         svnInfo.bb = int.Parse(v1);
 
-                     }
 
-                     if (key.Equals("URL"))
 
-                     {
 
-                         svnInfo.url = value;
 
-                     }
 
-                 }
 
-                 return svnInfo;
 
-             }
 
-             return null;
 
-         }
 
-         private void OnEnable()
 
-         {
 
-             SetSVNInfo();
 
-         }
 
-         private List<string> Proce(string par)
 
-         {
 
-             string allPath = UGUICacheInfo.uguiPackDB.uiPath2.Replace("unity_use_ui/", "工具/bin/svn.exe");
 
-             ProcessStartInfo processStartInfo = new System.Diagnostics.ProcessStartInfo(allPath,
 
-                 par);
 
-             processStartInfo.CreateNoWindow = true;
 
-             processStartInfo.UseShellExecute = false;
 
-             processStartInfo.RedirectStandardOutput = true;
 
-             processStartInfo.RedirectStandardError = true;
 
-             System.Diagnostics.Process process = new Process();
 
-             process.StartInfo = processStartInfo;
 
-             process.Start();
 
-             process.WaitForExit();
 
-             while (!process.StandardError.EndOfStream)
 
-             {
 
-                 return new List<string>();
 
-             }
 
-             List<string> allInfo = new List<string>();
 
-             while (!process.StandardOutput.EndOfStream)
 
-             {
 
-                 allInfo.Add(process.StandardOutput.ReadLine());
 
-             }
 
-             process.Close();
 
-             return allInfo;
 
-         }
 
-         private void OnGUI()
 
-         {
 
-             if (dbPath == null)
 
-             {
 
-                 Open();
 
-             }
 
-             if (UGUICacheInfo.uguiPackDB == null)
 
-             {
 
-                 return;
 
-             }
 
-             GUILayout.BeginHorizontal();
 
-             Color color = GUI.color;
 
-             if (bbh1 != 0 && bbh1 != bbh2)
 
-             {
 
-                 GUI.color = Color.red;
 
-                 if (GUILayout.Button("SVN有新的内容,请更新SVN"))
 
-                 {
 
-                 }
 
-             }
 
-             else
 
-             {
 
-             }
 
-             GUI.color = color;
 
-             GUILayout.Label($"远程版本号{bbh1}___本地版本号{bbh2}");
 
-             GUILayout.EndHorizontal();
 
-             if (GUILayout.Button("清空缓存"))
 
-             {
 
-                 PlayerPrefs.SetString("uiPath", "");
 
-                 UGUICacheInfo.Clare();
 
-             }
 
-             if (string.IsNullOrEmpty(UGUICacheInfo.uguiPackDB.uiPath2))
 
-             {
 
-                 if (GUILayout.Button("选在服务器UI"))
 
-                 {
 
-                     string path = EditorUtility.OpenFolderPanel("选择来源文件夹", "", "") + "/";
 
-                     if (!File.Exists(path + "art.config"))
 
-                     {
 
-                         EditorUtility.DisplayDialog("错误提示", "选择的文件夹错误,没有找到对应的美术配置", "确定");
 
-                     }
 
-                     else
 
-                     {
 
-                         PlayerPrefs.SetString("uiPath", path);
 
-                         UGUICacheInfo.uguiPackDB.uiPath2 = path;
 
-                         SetSVNInfo();
 
-                     }
 
-                 }
 
-                 return;
 
-             }
 
-             else if (!UGUICacheInfo.uguiPackDB.isJiaoYan)
 
-             {
 
-                 if (!File.Exists(UGUICacheInfo.uguiPackDB.uiPath2 + "art.config"))
 
-                 {
 
-                     EditorUtility.DisplayDialog("错误提示", "选择的文件夹错误,没有找到对应的美术配置", "确定");
 
-                     UGUICacheInfo.uguiPackDB.uiPath2 = null;
 
-                     return;
 
-                 }
 
-                 else
 
-                 {
 
-                     UGUICacheInfo.uguiPackDB.isJiaoYan = true;
 
-                 }
 
-             }
 
-             {
 
-                 if (GUILayout.Button("更新服务器UI到unity"))
 
-                 {
 
-                     UpdateArt();
 
-                 }
 
-             }
 
-             if (!UGUICacheInfo.uguiPackDB.isShowPack && GUILayout.Button("显示图集"))
 
-             {
 
-                 UGUICacheInfo.AllTextrueJsons.Clear();
 
-                 string targetFilePath = Application.dataPath + "/Art/UIAssets/TextrueJson";
 
-                 if (!Directory.Exists(targetFilePath))
 
-                 {
 
-                     return;
 
-                 }
 
-                 UGUICacheInfo.uguiPackDB.ClearUselessPack();
 
-                 string[] allFile = System.IO.Directory.GetFiles(targetFilePath, "*.txt"); //当前所有的图集
 
-                 for (int i = 0; i < allFile.Length; i++)
 
-                 {
 
-                     TextrueJson textrueJson = JsonUtility.FromJson<TextrueJson>(File.ReadAllText(allFile[i]));
 
-                     UGUICacheInfo.AllTextrueJsons.Add(textrueJson);
 
-                     PackInfo packInfo = UGUICacheInfo.uguiPackDB.GetPackgInfo(textrueJson.packName);
 
-                     string currGuid = GetFileMD5(allFile[i]);
 
-                     if (packInfo == null)
 
-                     {
 
-                         packInfo = UGUICacheInfo.AddNewPackInfo(allFile[i].Replace(Application.dataPath, ""),
 
-                             textrueJson);
 
-                     }
 
-                     else if (!string.IsNullOrEmpty(packInfo.packgJsonPath))
 
-                     {
 
-                         if (!File.Exists(Application.dataPath + packInfo.packgJsonPath))
 
-                         {
 
-                             packInfo.packgJsonPath = allFile[i].Replace(Application.dataPath, "");
 
-                         }
 
-                     }
 
-                     if (string.IsNullOrEmpty(packInfo.lasetJsonGUID) || !currGuid.Equals(packInfo.lasetJsonGUID))
 
-                     {
 
-                         packInfo.isUpdate = true;
 
-                     }
 
-                 }
 
-                 UGUICacheInfo.uguiPackDB.isShowPack = true;
 
-                 string json = JsonUtility.ToJson(UGUICacheInfo.uguiPackDB);
 
-                 File.WriteAllText(dbPath, json);
 
-             }
 
-             if (UGUICacheInfo.uguiPackDB.isShowPack && GUILayout.Button("隐藏图集"))
 
-             {
 
-                 UGUICacheInfo.uguiPackDB.isShowPack = false;
 
-             }
 
-             if (UGUICacheInfo.uguiPackDB.isShowPack)
 
-             {
 
-                 ShowPack();
 
-             }
 
-         }
 
-         private void ShowPack()
 
-         {
 
-             GUILayout.BeginHorizontal();
 
-             EditorGUILayout.LabelField("筛查");
 
-             findName = UnityEditor.EditorGUILayout.TextArea(findName);
 
-             if (GUILayout.Button("一键"))
 
-             {
 
-                 try
 
-                 {
 
-                     for (int j = 0; j < UGUICacheInfo.uguiPackDB.allPackgInfos.Count; j++)
 
-                     {
 
-                         PackInfo packInfo = UGUICacheInfo.uguiPackDB.allPackgInfos[j];
 
-                         SpriteAtlas spriteAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(packInfo.packgSpritePath);
 
-                         if (spriteAtlas == null)
 
-                         {
 
-                             continue;
 
-                         }
 
-                         string json = File.ReadAllText(Application.dataPath + packInfo.packgJsonPath);
 
-                         TextrueJson textrueJson = JsonUtility.FromJson<TextrueJson>(json);
 
-                         List<UnityEngine.Object> allAddAsset = new List<UnityEngine.Object>();
 
-                         UnityEngine.Object[] currObject = spriteAtlas.GetPackables();
 
-                         spriteAtlas.Remove(currObject);
 
-                         for (int i = 0; i < textrueJson.newTextureJson.Count; i++)
 
-                         {
 
-                             if (textrueJson.newTextureJson[i].textrueName.Contains("bg_"))
 
-                             {
 
-                                 continue;
 
-                             }
 
-                             if (string.IsNullOrEmpty(textrueJson.newTextureJson[i].textrueName))
 
-                             {
 
-                                 continue;
 
-                             }
 
-                             TextrueJson tongYong = UGUICacheInfo.GetTongYong(textrueJson.newTextureJson[i].textrueName);
 
-                             if (tongYong != null && !tongYong.packName.Equals(packInfo.packName))
 
-                             {
 
-                                 continue;
 
-                             }
 
-                             // string[] guidUI = AssetDatabase.FindAssets(textrueName);
 
-                             string textrueName = textrueJson.newTextureJson[i].textrueName;
 
-                             string[] guidUI = AssetDatabase.FindAssets(textrueName);
 
-                             if (guidUI != null && guidUI.Length > 0)
 
-                             {
 
-                                 for (int k = 0; k < guidUI.Length; k++)
 
-                                 {
 
-                                     string path = AssetDatabase.GUIDToAssetPath(guidUI[k]);
 
-                                     if (!path.Contains(".png"))
 
-                                     {
 
-                                         continue;
 
-                                     }
 
-                                     UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(path);
 
-                                     TextureImporter emojiTex = AssetImporter.GetAtPath(path) as TextureImporter;
 
-                                     if (emojiTex != null && emojiTex.textureType != TextureImporterType.Sprite)
 
-                                     {
 
-                                         emojiTex.textureType = TextureImporterType.Sprite;
 
-                                         emojiTex.SaveAndReimport();
 
-                                     }
 
-                                     if (!obj.name.Equals(textrueName))
 
-                                     {
 
-                                         continue;
 
-                                     }
 
-                                     allAddAsset.Add(obj);
 
-                                     break;
 
-                                 }
 
-                                 // string path = AssetDatabase.GUIDToAssetPath(guidUI[0]);
 
-                                 // if (!path.Contains(".png"))
 
-                                 // {
 
-                                 //     continue;
 
-                                 // }
 
-                                 //
 
-                                 // UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(path);
 
-                                 // TextureImporter emojiTex = AssetImporter.GetAtPath(path) as TextureImporter;
 
-                                 // if (emojiTex != null && emojiTex.textureType != TextureImporterType.Sprite)
 
-                                 // {
 
-                                 //     emojiTex.textureType = TextureImporterType.Sprite;
 
-                                 //     emojiTex.SaveAndReimport();
 
-                                 // }
 
-                                 //
 
-                                 // allAddAsset.Add(obj);
 
-                             }
 
-                         }
 
-                         spriteAtlas.SetIncludeInBuild(false);
 
-                         SpriteAtlasExtensions.Add(spriteAtlas, allAddAsset.ToArray());
 
-                         EditorUtility.SetDirty(spriteAtlas);
 
-                         SpriteAtlasUtility.PackAtlases(new SpriteAtlas[] { spriteAtlas }, BuildTarget.Android);
 
-                         packInfo.lasetJsonGUID = GetFileMD5(Application.dataPath + packInfo.packgJsonPath);
 
-                         packInfo.isUpdate = false;
 
-                         string dbjson = JsonUtility.ToJson(UGUICacheInfo.uguiPackDB);
 
-                         File.WriteAllText(dbPath, dbjson);
 
-                     }
 
-                     // UGUIGameObjectTool.ReviewUI(UGUICacheInfo.atlasList, spriteAtlas, packInfo);
 
-                 }
 
-                 catch (Exception e)
 
-                 {
 
-                     Debug.LogError(e);
 
-                 }
 
-                 AssetDatabase.SaveAssets();
 
-                 AssetDatabase.Refresh();
 
-             }
 
-             GUILayout.EndHorizontal();
 
-             int maxHeight = UGUICacheInfo.uguiPackDB.allPackgInfos.Count * (356) + 1000;
 
-             pos = GUI.BeginScrollView(
 
-                 new Rect(0, 100, EditorGUIUtility.currentViewWidth, this.position.height), pos,
 
-                 new Rect(0, 0, 10000, maxHeight), false, true);
 
-             Rect rect = new Rect(0, 70, 0, 0);
 
-             for (int i = 0; i < UGUICacheInfo.uguiPackDB.allPackgInfos.Count; i++)
 
-             {
 
-                 PackInfo packInfo = UGUICacheInfo.uguiPackDB.allPackgInfos[i];
 
-                 if (!string.IsNullOrEmpty(findName) && !packInfo.packName.Contains(findName))
 
-                 {
 
-                     continue;
 
-                 }
 
-                 // if ((!packInfo.isUpdate || string.IsNullOrEmpty(packInfo.packgSpritePath)))
 
-                 // {
 
-                 //     continue;
 
-                 // }
 
-                 DrawPack(packInfo, rect);
 
-                 rect.y += 256 + 100;
 
-             }
 
-             GUI.EndScrollView();
 
-         }
 
-         private void DrawPack(PackInfo packInfo, Rect rect)
 
-         {
 
-             GUI.Box(new Rect(0, rect.y - 20, EditorGUIUtility.currentViewWidth - 180, 300), "");
 
-             GUILayout.BeginHorizontal();
 
-             float x = 30;
 
-             GUI.Label(new Rect(x, rect.y + 10, 200, 30), packInfo.packName);
 
-             x += 200;
 
-             if (packInfo.isPackError)
 
-             {
 
-                 x += 50;
 
-                 if (GUI.Button(new Rect(x, rect.y, 50, 30), "校验" + packInfo.packName))
 
-                 {
 
-                     packInfo.isPackError = false;
 
-                 }
 
-             }
 
-             x += 50;
 
-             Rect buttonRect = new Rect(x, rect.y, 50, 50);
 
-             if (GUI.Button(buttonRect, "更新"))
 
-             {
 
-                 SpriteAtlas spriteAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(packInfo.packgSpritePath);
 
-                 if (spriteAtlas == null)
 
-                 {
 
-                     return;
 
-                 }
 
-                 string json = File.ReadAllText(Application.dataPath + packInfo.packgJsonPath);
 
-                 TextrueJson textrueJson = JsonUtility.FromJson<TextrueJson>(json);
 
-                 List<UnityEngine.Object> allAddAsset = new List<UnityEngine.Object>();
 
-                 UnityEngine.Object[] currObject = spriteAtlas.GetPackables();
 
-                 SpriteAtlasExtensions.Remove(spriteAtlas, currObject);
 
-                 spriteAtlas.Remove(currObject);
 
-                 // spriteAtl = 0;
 
-                 for (int i = 0; i < textrueJson.newTextureJson.Count; i++)
 
-                 {
 
-                     string textrueName = textrueJson.newTextureJson[i].textrueName;
 
-                     if (textrueName.Contains("bg_"))
 
-                     {
 
-                         continue;
 
-                     }
 
-                     if (string.IsNullOrEmpty(textrueName))
 
-                     {
 
-                         continue;
 
-                     }
 
-                     TextrueJson tongYong = UGUICacheInfo.GetTongYong(textrueName);
 
-                     if (tongYong != null && !tongYong.packName.Equals(packInfo.packName))
 
-                     {
 
-                         continue;
 
-                     }
 
-                     string[] guidUI = AssetDatabase.FindAssets(textrueName);
 
-                     if (guidUI != null && guidUI.Length > 0)
 
-                     {
 
-                         for (int j = 0; j < guidUI.Length; j++)
 
-                         {
 
-                             string path = AssetDatabase.GUIDToAssetPath(guidUI[j]);
 
-                             if (!path.Contains(".png"))
 
-                             {
 
-                                 continue;
 
-                             }
 
-                             UnityEngine.Object obj = AssetDatabase.LoadMainAssetAtPath(path);
 
-                             TextureImporter emojiTex = AssetImporter.GetAtPath(path) as TextureImporter;
 
-                             if (emojiTex != null && emojiTex.textureType != TextureImporterType.Sprite)
 
-                             {
 
-                                 emojiTex.textureType = TextureImporterType.Sprite;
 
-                                 emojiTex.SaveAndReimport();
 
-                             }
 
-                             if (!obj.name.Equals(textrueName))
 
-                             {
 
-                                 continue;
 
-                             }
 
-                             allAddAsset.Add(obj);
 
-                             break;
 
-                         }
 
-                     }
 
-                 }
 
-                 spriteAtlas.SetIncludeInBuild(false);
 
-                 SpriteAtlasAsset spriteAtlasAsset = SpriteAtlasAsset.Load(packInfo.packgSpritePath);
 
-                 MethodInfo methodInfo = spriteAtlasAsset.GetType()
 
-                     .GetMethod("RemoveAt", BindingFlags.Instance | BindingFlags.NonPublic);
 
-                 for (int i = 0; i < spriteAtlas.spriteCount * 3; i++)
 
-                 {
 
-                     methodInfo.Invoke(spriteAtlasAsset, new object[] { 0 });
 
-                 }
 
-                 // spriteAtlasAsset.Remove(sprites);
 
-                 spriteAtlasAsset.Add(allAddAsset.ToArray());
 
-                 SpriteAtlasAsset.Save(spriteAtlasAsset, packInfo.packgSpritePath);
 
-                 // spriteAtlasAsset.
 
-                 EditorUtility.SetDirty(spriteAtlas);
 
-                 AssetDatabase.SaveAssets();
 
-                 SpriteAtlasUtility.PackAtlases(new SpriteAtlas[] { spriteAtlas }, BuildTarget.NoTarget);
 
-                 AssetDatabase.Refresh();
 
-                 packInfo.lasetJsonGUID = GetFileMD5(Application.dataPath + packInfo.packgJsonPath);
 
-                 packInfo.isUpdate = false;
 
-                 string dbjson = JsonUtility.ToJson(UGUICacheInfo.uguiPackDB);
 
-                 File.WriteAllText(dbPath, dbjson);
 
-                 UGUIGameObjectTool.ReviewUI(UGUICacheInfo.atlasList, spriteAtlas, packInfo);
 
-             }
 
-             if (string.IsNullOrEmpty(packInfo.packgSpritePath) || packInfo.spriteAtlas == null)
 
-             {
 
-                 x += 50;
 
-                 buttonRect = new Rect(x, rect.y, 50, 50);
 
-                 if (GUI.Button(buttonRect, "创建"))
 
-                 {
 
-                     string path = "Assets/Res/UIAtlas/";
 
-                     // string defaultPath = path + "default.spriteatlas";
 
-                     string assetPath = Application.dataPath.Replace("Assets", "") + path + packInfo.packName +
 
-                                        ".spriteatlasv2";
 
-                     if (!File.Exists(assetPath))
 
-                     {
 
-                         string n = path + "MoBan.spriteatlasv2";
 
-                         string newP = path + packInfo.packName + ".spriteatlasv2";
 
-                         AssetDatabase.CopyAsset(n, newP);
 
-                         // SpriteAtlas spriteAtlas = new SpriteAtlas();
 
-                         // AssetDatabase.CreateAsset(spriteAtlas, path + packInfo.packName + ".spriteatlasv2");
 
-                         AssetDatabase.ImportAsset(path + packInfo.packName + ".spriteatlasv2");
 
-                         AssetDatabase.SaveAssets();
 
-                         SpriteAtlas spriteAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(newP);
 
-                         UGUICacheInfo.atlasList.Add(spriteAtlas);
 
-                         packInfo.spriteAtlas = spriteAtlas;
 
-                         // AssetDatabase.Refresh();
 
-                         // File.Copy(Application.dataPath.Replace("Assets", "") + defaultPath, assetPath);
 
-                         // AssetDatabase.Refresh();
 
-                         // AssetDatabase.SaveAssets();
 
-                     }
 
-                     packInfo.isUpdate = true;
 
-                     packInfo.packgSpritePath = path + packInfo.packName + ".spriteatlasv2";
 
-                     string json = JsonUtility.ToJson(UGUICacheInfo.uguiPackDB);
 
-                     File.WriteAllText(dbPath, json);
 
-                 }
 
-             }
 
-             x += 50;
 
-             Rect shuaXing = new Rect(x, rect.y, 50, 50);
 
-             if (GUI.Button(shuaXing, "刷新"))
 
-             {
 
-                 SpriteAtlas spriteAtlas = AssetDatabase.LoadAssetAtPath<SpriteAtlas>(packInfo.packgSpritePath);
 
-                 if (spriteAtlas != null)
 
-                 {
 
-                     UGUIGameObjectTool.ReviewUI(UGUICacheInfo.atlasList, spriteAtlas, packInfo);
 
-                 }
 
-             }
 
-             if (packInfo.packName != null && packInfo.spriteAtlas == null && packInfo.isPackError == false)
 
-             {
 
-                 packInfo.spriteAtlas = UGUICacheInfo.GetSpriteAtlas(packInfo.packName);
 
-                 if (packInfo.spriteAtlas == null)
 
-                 {
 
-                     packInfo.lasetJsonGUID = null;
 
-                     packInfo.isPackError = true;
 
-                 }
 
-                 else
 
-                 {
 
-                     packInfo.packgSpritePath = AssetDatabase.GetAssetPath(packInfo.spriteAtlas);
 
-                 }
 
-                 UGUICacheInfo.SaveDB();
 
-             }
 
-             if (packInfo.spriteAtlas != null)
 
-             {
 
-                 x += 50;
 
-                 EditorGUI.ObjectField(new Rect(x, rect.y, 150, 50), packInfo.spriteAtlas, typeof(SpriteAtlas));
 
-                 x += 150;
 
-                 if (GUI.Button(new Rect(x, rect.y, 50, 50), "删除"))
 
-                 {
 
-                     AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(packInfo.spriteAtlas));
 
-                     packInfo.spriteAtlas = null;
 
-                     AssetDatabase.Refresh();
 
-                 }
 
-             }
 
-             GUILayout.EndHorizontal();
 
-             // rect.y += 50;
 
-             // if (packInfo.spriteAtlas != null)
 
-             // {
 
-             //     Rect scrolViewRect = new Rect(0, rect.y, EditorGUIUtility.currentViewWidth - 200, 256);
 
-             //     MethodInfo getPreviewTextures = packInfo.spriteAtlas.GetType()
 
-             //         .GetMethod("GetPreviewTextures");
 
-             //     Texture2D[] allTack = (Texture2D[])getPreviewTextures.Invoke(packInfo.spriteAtlas, null);
 
-             //     // Texture2D[] allTack = packInfo.spriteAtlas.GetPreviewTextures();
 
-             //     packInfo.movePos = GUI.BeginScrollView(scrolViewRect, packInfo.movePos,
 
-             //         new Rect(0, 0, allTack.Length * 356, 250), false, false);
 
-             //
 
-             //
 
-             //     Rect textrueRect = new Rect(30, 0, 256, 256);
 
-             //     for (int i = 0; i < allTack.Length; i++)
 
-             //     {
 
-             //         GUI.DrawTexture(textrueRect, allTack[i], ScaleMode.ScaleToFit);
 
-             //         textrueRect.x += 256 + 100;
 
-             //     }
 
-             //
 
-             //     GUI.EndScrollView();
 
-             // }
 
-         }
 
-         private void UpdateArt()
 
-         {
 
-             string[] scorPath = Directory.GetFiles(UGUICacheInfo.uguiPackDB.uiPath2, "*", SearchOption.AllDirectories);
 
-             string[] targetPath =
 
-                 Directory.GetFiles(Application.dataPath + "/Art/UIAssets", "*", SearchOption.AllDirectories);
 
-             //更新资源
 
-             UpdateFile(scorPath);
 
-             DelectFile(targetPath);
 
-         }
 
-         private void DelectFile(string[] targetPath)
 
-         {
 
-             for (int i = 0; i < targetPath.Length; i++)
 
-             {
 
-                 string filePath = targetPath[i].Replace("\\", "/");
 
-                 filePath = UGUICacheInfo.uguiPackDB.uiPath2 +
 
-                            filePath.Replace(Application.dataPath + "/Art/UIAssets/", "");
 
-                 if (filePath.Contains(".meta") || filePath.Contains("TextureSettingConfig") ||
 
-                     filePath.Contains("dbdata") || filePath.Contains("art.config"))
 
-                 {
 
-                     continue;
 
-                 }
 
-                 if (!File.Exists(filePath))
 
-                 {
 
-                     File.Delete(targetPath[i]);
 
-                 }
 
-             }
 
-             AssetDatabase.SaveAssets();
 
-             AssetDatabase.Refresh();
 
-         }
 
-         private void UpdateFile(string[] scorPath)
 
-         {
 
-             for (int i = 0; i < scorPath.Length; i++)
 
-             {
 
-                 if (scorPath[i].Contains(".svn"))
 
-                 {
 
-                     continue;
 
-                 }
 
-                 string filePath = scorPath[i].Replace(UGUICacheInfo.uguiPackDB.uiPath2, "");
 
-                 string scorFilePath = scorPath[i];
 
-                 string targetFilePath = Application.dataPath + "/Art/UIAssets/" + filePath;
 
-                 string dirPath = targetFilePath.Replace(Path.GetFileName(scorFilePath), "");
 
-                 if (!System.IO.Directory.Exists(dirPath))
 
-                 {
 
-                     Directory.CreateDirectory(dirPath);
 
-                 }
 
-                 if (File.Exists(targetFilePath)) //替换
 
-                 {
 
-                     string sucMd5 = GetFileMD5(scorFilePath);
 
-                     string taggetMd5 = GetFileMD5(targetFilePath);
 
-                     if (!sucMd5.Equals(taggetMd5)) //图片变化
 
-                     {
 
-                         string fileName = Path.GetFileNameWithoutExtension(scorFilePath);
 
-                         File.Copy(scorFilePath, targetFilePath, true);
 
-                         AssetDatabase.ImportAsset(targetFilePath.Replace(Application.dataPath, "Assets"),
 
-                             ImportAssetOptions.ForceUpdate);
 
-                         TextureImporter emojiTex =
 
-                             AssetImporter.GetAtPath(targetFilePath.Replace(Application.dataPath, "Assets")) as
 
-                                 TextureImporter;
 
-                         if (emojiTex != null)
 
-                         {
 
-                             emojiTex.textureType = TextureImporterType.Sprite;
 
-                             emojiTex.SaveAndReimport();
 
-                         }
 
-                     }
 
-                 }
 
-                 else //新加
 
-                 {
 
-                     try
 
-                     {
 
-                         if (!scorFilePath.Contains("效果图"))
 
-                         {
 
-                             // AssetDatabase.ImportAsset(scorFilePath);
 
-                             File.Copy(scorFilePath, targetFilePath, true);
 
-                             AssetDatabase.ImportAsset(targetFilePath.Replace(Application.dataPath, "Assets"),
 
-                                 ImportAssetOptions.ForceUpdate);
 
-                             TextureImporter emojiTex =
 
-                                 AssetImporter.GetAtPath(targetFilePath.Replace(Application.dataPath, "Assets")) as
 
-                                     TextureImporter;
 
-                             if (emojiTex != null)
 
-                             {
 
-                                 emojiTex.textureType = TextureImporterType.Sprite;
 
-                                 emojiTex.SaveAndReimport();
 
-                             }
 
-                         }
 
-                     }
 
-                     catch (System.Exception e)
 
-                     {
 
-                         Debug.LogError(e);
 
-                     }
 
-                 }
 
-                 //string 
 
-             }
 
-             string[] jsonPath = Directory.GetFiles(UGUICacheInfo.uguiPackDB.uiPath2 + "TextrueJson", "*.txt",
 
-                 SearchOption.AllDirectories);
 
-             for (int i = 0; i < jsonPath.Length; i++)
 
-             {
 
-                 string filePath = jsonPath[i].Replace(UGUICacheInfo.uguiPackDB.uiPath2, "");
 
-                 string scorFilePath = jsonPath[i];
 
-                 string targetFilePath = Application.dataPath + "/Art/UIAssets/" + filePath;
 
-                 File.Copy(scorFilePath, targetFilePath, true);
 
-             }
 
-             AssetDatabase.SaveAssets();
 
-             AssetDatabase.Refresh();
 
-         }
 
-         private string GetFileMD5(string filePath)
 
-         {
 
-             FileStream file = new FileStream(filePath, System.IO.FileMode.Open);
 
-             MD5 md5 = new MD5CryptoServiceProvider();
 
-             byte[] retVal = md5.ComputeHash(file);
 
-             file.Close();
 
-             file.Dispose();
 
-             StringBuilder sb = new StringBuilder();
 
-             for (int i = 0; i < retVal.Length; i++)
 
-             {
 
-                 sb.Append(retVal[i].ToString("x2"));
 
-             }
 
-             return sb.ToString();
 
-         }
 
-     }
 
- }
 
 
  |