I’m just learning the new UI Toolkit and I found that I could instantiate a TextElement class.
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
[CustomEditor(typeof(MeshFilter))]
public class Inspector : Editor
{
private VisualElement _root;
public override VisualElement CreateInspectorGUI()
{
return _root;
}
public void OnEnable()
{
_root = new VisualElement();
TextElement textElement = new TextElement();
textElement.text = "Some Text";
_root.Add(textElement);
}
}
Is this expected behaviour?