using System.Collections; using System.Collections.Generic; using System.IO; using DG.Tweening; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UIElements; using System.Reflection; using System; using System.Linq; public class AutoGenerate : EditorWindow { #region Component private VisualElement root; private Label titleText; private Label hintText; private Toggle testScene; private Toggle spriteFile; //动态文件夹 private Button generateBtn; private TextField nameInput; #endregion #region Path private string scenePath; private string scriptPath; private string prefabPath; private string uiSpritePath; private string uiSpritePath1; #endregion [MenuItem("Window/Generate Editor Window")] public static void ShowExample() { AutoGenerate wnd = GetWindow(); wnd.titleContent = new GUIContent("Auto Generate UI Window"); } public void CreateGUI() { scenePath = "Assets/SandBox/TestUIPanelScenes"; scriptPath = "Assets/Project/UI/UI_Panel"; prefabPath = "Assets/Resources/UI/UI_Panel"; uiSpritePath = "Assets/ArtRes/Sprite/UI_Panel"; uiSpritePath1 = "Assets/Resources/Sprites"; // scenePath = "Assets/Test1"; // scriptPath = "Assets/Test2"; // prefabPath = "Assets/Test3"; // var visualTree = // AssetDatabase.LoadAssetAtPath( // "Assets/ThirdPart/UIToolKitFile/UDoc/UXml/AutoGenerateUI.uxml"); // rootElement = visualTree.CloneTree(); root = rootVisualElement; titleText = new Label("自动生成ui预制体,脚本,静态sprite文件夹,动态sprite文件夹(可选),测试场景(可选),"); hintText = new Label(""); testScene = new Toggle(); testScene.label = "创建测试场景?"; spriteFile = new Toggle(); spriteFile.label = "创建动态sprite文件夹?"; generateBtn = new Button(); generateBtn.text = "自动生成按钮"; nameInput = new TextField("预制体名(也是脚本名)"); root.Add(titleText); root.Add(hintText); root.Add(testScene); root.Add(spriteFile); root.Add(nameInput); root.Add(generateBtn); // rootVisualElement.Add(rootElement); // generateBtn = rootElement.Q