When making a custom Editor I can declare a serialised VisualTreeAsset, plug it in to a UXML file in the editor, clone it into a VisualElement and then return that in CreateInspectorGUI().
When making a custom PropertyDrawer the VisualTreeAsset seemingly cannot be exposed in order to do this; it just doesn’t appear in the inspector. Therefore, how can I use UI Builder to create the visuals for my PropertyDrawer? Also, just as an aside, why doesn’t this method seem to work for both?
The feature you are using for setting the VisualTreeAsset is only available for scripts inheriting from UnityEngine.Object. The Editor class derives from it, so you can set “default” values for the serializable fields for any new instance of that type.
PropertyDrawers, however, dont inherit from UnityEngine.Object, so you should instead use the “Resources” approach.
As these are “Editor-only” files, you should place the UXML asset inside a folder named “Resources”, located inside a folder named “Editor” (this way you prevent it being included in build).
You can then load the VisualTreeAsset using EditorGUIUtility.Load(string path) (path must be relative to the Resources folder)
var uxml = (VisualTreeAsset)EditorGUIUtility.Load("MyUXML")