Custom HUD Hierarchy in Editor Window

I am developing a game using Unity and since the beginning it was clear to me that I would implement a custom way to draw the HUD, which I have achieved easily, using a hierarchical structure of HUDObjects. The way I have been implementing this structure is simply storing a list of children HUDObjects in each HUDObject and then recursively drawing them. This has worked out fine for me so far, but as the project is growing in size, I am finding it more and more tedious and confusing to navigate to each individual HUDObject to traverse the HUD tree.

I have always been impressed by Unity’s extendability, particularly with the Editor, so I looked into a creating a custom HUD Editor Window. I found that I could certainly draw the hierarchy out, using a series of Foldouts, but it didn’t give me the level of interactivity I wanted. What I basically am looking to achieve the Unity’s Scene Hierarchy Window, but for my custom HUDObjects, where I can drag them around to reparent them in the heirarchy. I am simply wondering if this is at all possible and if someone could at least point me in the right direction to go with this, I would be very grateful.

Thanks for reading my wordy question!

I just went through this for my latest asset store product where I wanted to have a tree control. It’s totally possible, but you have to do almost everything yourself. There’s no built in tree control widget, and even foldouts only go so far. I think there is a tree control widget you can buy on the asset store, but last I checked it was more targeted to in-game GUIs.

If it’s just the number/complexity of the objects in the hierarchy that’s a problem, you might find it more productive to just use the filtering/search options built into the scene hierarchy view.

So as far as I can tell, there is no way to directly imitate the Hierarchy view. However, using a combination of a GUI drag-drop script by AngryAnt and Unity’s DragAndDrop class I have managed to achieve something functional. I use AngryAnt’s script to draw the actual hierarchy. It’s a very simple system which uses the Unity Event functionality to detect when a drag is occurring and simply draw the offending draggable object relative to the mouse position. Because my HUDObjects are ScriptableObjects underneath, I store them as actual assets in the project, so to get them from the Project view into this hierarchy view I had to use Unity’s DragAndDrop class. Relatively simple to use, I only use the AcceptDrag function, then simply iterate over the DragAndDrop.objectReferences and add each HUDObject into the hierarchy.