CombatR.cs 853 B

123456789101112131415161718192021222324252627282930
  1. using UnityEditor;
  2. using UnityEngine;
  3. using UnityEngine.UIElements;
  4. public class CombatR : EditorWindow
  5. {
  6. [SerializeField]
  7. private VisualTreeAsset m_VisualTreeAsset = default;
  8. [MenuItem("Window/UI Toolkit/CombatR")]
  9. public static void ShowExample()
  10. {
  11. CombatR wnd = GetWindow<CombatR>();
  12. wnd.titleContent = new GUIContent("CombatR");
  13. }
  14. public void CreateGUI()
  15. {
  16. // Each editor window contains a root VisualElement object
  17. VisualElement root = rootVisualElement;
  18. // VisualElements objects can contain other VisualElement following a tree hierarchy.
  19. VisualElement label = new Label("Hello World! From C#");
  20. root.Add(label);
  21. // Instantiate UXML
  22. VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate();
  23. root.Add(labelFromUXML);
  24. }
  25. }