using UnityEditor; using UnityEditor.Animations; using UnityEngine; using UnityEngine.UIElements; public class SimpleCustomEditor : EditorWindow { [MenuItem("Window/UI Toolkit/MyCustomEditor")] public static void ShowExample() { SimpleCustomEditor wnd = GetWindow(); wnd.titleContent = new GUIContent("MyCustomEditor"); } [SerializeField] private VisualTreeAsset m_UXMLTree = default; private int m_ClickCount = 0; private const string m_ButtonPrefix = "button"; public void CreateGUI() { // Each editor window contains a root VisualElement object VisualElement root = rootVisualElement; // VisualElements objects can contain other VisualElement following a tree hierarchy. Label label = new Label("These controls were created using C# code."); root.Add(label); Button button = new Button(); button.name = "button3"; button.text = "This is button3."; root.Add(button); Toggle toggle = new Toggle(); toggle.name = "toggle3"; toggle.label = "Number?"; root.Add(toggle); // Instantiate UXML created automatically which is set as the default VisualTreeAsset. root.Add(m_UXMLTree.Instantiate()); // Import UXML created manually. var visualTree = AssetDatabase.LoadAssetAtPath("Assets/Editor/UXML/Editor Simple/SimpleCustomEditor_uxml.uxml"); VisualElement labelFromUXML_uxml = visualTree.Instantiate(); root.Add(labelFromUXML_uxml); //Call the event handler SetupButtonHandler(); } //Functions as the event handlers for your button click and number counts private void SetupButtonHandler() { VisualElement root = rootVisualElement; var buttons = root.Query