Manual/UIE-LoadingUXMLcsharp #666
Replies: 1 comment
-
|
A template for an EditorWindow using Unity Toolkit with the TemplateContainer: if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class CustomWindow : EditorWindow
{
[SerializeField] VisualTreeAsset uxml;
[SerializeField] StyleSheet uss;
[MenuItem("Tools/" + nameof(CustomWindow))]
public static void ShowWindow()
{
GetWindow<CustomWindow>(nameof(CustomWindow));
}
void CreateGUI()
{
TemplateContainer templateContainer = uxml.Instantiate();
templateContainer.styleSheets.Add(uss);
rootVisualElement.Add(templateContainer);
}
}Without the template container: if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
public class CustomWindow : EditorWindow
{
[SerializeField] VisualTreeAsset uxml;
[SerializeField] StyleSheet uss;
[MenuItem("Tools/" + nameof(CustomWindow))]
public static void ShowWindow()
{
GetWindow<CustomWindow>(nameof(CustomWindow));
}
void CreateGUI()
{
uxml.CloneTree(rootVisualElement);
rootVisualElement.styleSheets.Add(uss);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Manual/UIE-LoadingUXMLcsharp
https://docs.unity3d.com/Manual/UIE-LoadingUXMLcsharp.html
Beta Was this translation helpful? Give feedback.
All reactions