using System; using System.Collections; using System.Collections.Generic; using System.IO; using UnityEngine; using UnityEngine.UI.PackgTool; namespace UnityEditor.UI { public class UGUIFunctiontemplateWindow : EditorWindow { private static System.Action callBack; public static void OpenWidow(System.Action callBack) { UGUIFunctiontemplateWindow.callBack = callBack; EditorWindow.GetWindow().Show(); } public string functionPathJson = "/Art/UIAssets/TextrueJson"; Vector2 pos = Vector2.zero; private string _currSelectName; private void OnGUI() { string path = Application.dataPath + functionPathJson; string[] allPath = System.IO.Directory.GetFiles(path, "*.txt"); List gameAllModel = new List(); for (int i = 0; i < allPath.Length; i++) { string jsonPath = File.ReadAllText(allPath[i]); TextrueJson textrueJson = JsonUtility.FromJson(jsonPath); gameAllModel.Add(textrueJson); } _currSelectName= GUILayout.TextArea(_currSelectName,"筛选" ); pos = GUILayout.BeginScrollView(pos); for (int i = 0; i < gameAllModel.Count; i++) { if (!string.IsNullOrEmpty(_currSelectName)&&_currSelectName!=""&&!gameAllModel[i].packName.Contains(_currSelectName)) { continue; } if (GUILayout.Button(gameAllModel[i].packName)) { Close(); PackInfo packInfo= UGUICacheInfo.GetPackDB(gameAllModel[i].packName); if (packInfo == null) { packInfo= UGUICacheInfo.AddNewPackInfo(allPath[i].Replace(Application.dataPath, ""), gameAllModel[i]); } callBack?.Invoke(packInfo); } } GUILayout.EndScrollView(); } } }