It kinda seems to me like nobody is using UI Toolkit editor binding correctly. The problem here is that there doesn’t seem to be any usable documentation on the topic. I’ve been scouring the internet trying to find the correct way to create our own BindableElement for use in-editor, with SerializedObject and SerializedProperty, but I’ve yet to turn up any usable results.
For example, say I wanted to set up a complex PropertyDrawer and an associated VisualElement
First we need to create CustomDrawer, a simple PropertyDrawer used to create the element, bind it, and return it:
public class CustomDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
CustomField field = new CustomField();
field.BindProperty(property);
return field;
}
}
From there, we create CustomElement (a VisualElement) to visualize our object in-editor. This is the part I’m stuck on.
Up until now, I’ve just implemented my own BindProperty(SerializeProperty p) method, without inheriting from BindableElement, or implementing IBindable or IBinding. I know this is the wrong way to go about it and I’d love to know the right way to do it.
What is the intended way to set this up? The documentation seems to be completely lacking here. How do we make our own VisualElement with similar editor Binding functionality to FloatField, ObjectField, PropertyField, etc?