Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEditor;
- using UnityEngine;
- using UnityEngine.UIElements;
- public class customEditor : EditorWindow
- {
- private VisualElement _root;
- private VisualTreeAsset _treeAsset;
- [MenuItem("Window/UI Toolkit/customEditor")]
- public static void ShowExample()
- {
- customEditor wnd = GetWindow<customEditor>();
- wnd.titleContent = new GUIContent("customEditor");
- }
- public void CreateGUI()
- {
- _root = rootVisualElement;
- _treeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>("Assets/Editor/customEditor.uxml");
- Button button = _root.Query<Button>("button-Test");
- button.clickable.clicked += ButtonClicked;
- VisualElement labelFromUXML = _treeAsset.Instantiate();
- _root.Add(labelFromUXML);
- }
- private void ButtonClicked()
- {
- Debug.Log("Test");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement