@@ -22,6 +22,8 @@ namespace BrunoMikoski.ScriptableObjectCollections
2222 [ CustomEditor ( typeof ( ScriptableObjectCollection ) , true ) ]
2323 public class CollectionCustomEditor : Editor
2424 {
25+ private const string COLLECTION_EDITOR_UXML_PATH = "Packages/com.brunomikoski.scriptableobjectcollection/Editor/UXML/CollectionCustomEditorTreeAsset.uxml" ;
26+ private const string COLLECTION_ITEM_UXML_PATH = "Packages/com.brunomikoski.scriptableobjectcollection/Editor/UXML/CollectionItemTreeAsset.uxml" ;
2527 private const string WAITING_FOR_SCRIPT_TO_BE_CREATED_KEY = "WaitingForScriptTobeCreated" ;
2628 private static ScriptableObject LAST_ADDED_COLLECTION_ITEM ;
2729
@@ -113,6 +115,15 @@ public static ScriptableObject AddNewItem(ScriptableObjectCollection collection,
113115 public override VisualElement CreateInspectorGUI ( )
114116 {
115117 VisualElement root = new ( ) ;
118+ EnsureVisualTreeAssetsAreLoaded ( ) ;
119+ if ( visualTreeAsset == null || collectionItemVisualTreeAsset == null )
120+ {
121+ root . Add ( new HelpBox (
122+ "Could not load Collection editor UI assets. Reimport 'com.brunomikoski.scriptableobjectcollection' package or restore missing UXML files." ,
123+ HelpBoxMessageType . Error ) ) ;
124+ return root ;
125+ }
126+
116127 visualTreeAsset . CloneTree ( root ) ;
117128
118129 collection = ( ScriptableObjectCollection ) target ;
@@ -254,12 +265,28 @@ public override VisualElement CreateInspectorGUI()
254265 ToolbarSearchField toolbarSearchField = root . Q < ToolbarSearchField > ( ) ;
255266 toolbarSearchField . RegisterValueChangedCallback ( OnSearchInputChanged ) ;
256267
268+ IMGUIContainer additionalIMGUIContainer = new IMGUIContainer ( DrawAdditionalIMGUI ) ;
269+ root . Add ( additionalIMGUIContainer ) ;
270+
257271
258272 root . schedule . Execute ( OnVisualTreeCreated ) . ExecuteLater ( 100 ) ;
259273
260274 return root ;
261275 }
262276
277+ private void EnsureVisualTreeAssetsAreLoaded ( )
278+ {
279+ if ( visualTreeAsset == null )
280+ visualTreeAsset = AssetDatabase . LoadAssetAtPath < VisualTreeAsset > ( COLLECTION_EDITOR_UXML_PATH ) ;
281+
282+ if ( collectionItemVisualTreeAsset == null )
283+ collectionItemVisualTreeAsset = AssetDatabase . LoadAssetAtPath < VisualTreeAsset > ( COLLECTION_ITEM_UXML_PATH ) ;
284+ }
285+
286+ protected virtual void DrawAdditionalIMGUI ( )
287+ {
288+ }
289+
263290 private void UpdateAutomaticallyLoaded ( )
264291 {
265292 CollectionsRegistry . Instance . UpdateAutoSearchForCollections ( ) ;
0 commit comments