Tree-View Control for Unity 5.0+ UI
This is a TreeView control for the Unity 5.0 UI system. It features a collapsing and expanding hierarchical control that allows dynamic script-mediated generation, ordering, and interaction of a TreeView hierarchy at runtime.
IMPORTANT: This is not a control that can be designed in the editor other than placing the root control object. To utilize this control, you drop the root object into your scene and then you must dynamically add objects to it via script via a simple three parameter "CreateObject" Method (see "Extended Demonstration" video for demonstration of this).
Each object in the control is required to have the same height.
Some of the primary features of this control are:
1. An automatically resizing frame to allow it to always fit snugly into a ScrollRect (with minimum and maximum values to ensure it doesn't get to small or big). The frame resizes itself every time you expand or retract a branch of the tree, so its frame will always be the perfect size for its contents.
2. An event interface allowing easy interaction with any number user-made modules for attachment to the hierarchy of the TreeView.
3. Customizable padding between menu objects and arbitrary size controls.
4. Works in both world-space and overlay canvases.
5. The ability to arbitrarily sort branches of the control via script.
6. Customizable "arrow" drop down toggle sprites that allow for any square sprite to act as the toggle.
7. Comes with two pre-made modules, a "Text" field and a toggle module. The modules automatically size to fit the text's contents.
Note: knowledge of C# events and delegates is necessary to work with this control. Knowledge of C# interfaces, down and up casting from the base "object" type, and events and delegates is necessary to make custom modules that can be added to the hierarchy.
Caveat: Because this is built in the "new" GUI system, this class generates a lot of game objects depending on the size of your hierarchy. Without the modules, each branch in the hierarchy creates three GameObjects, so it is not recommended to use this on mobile for large hierarchies and it is not recommended for frequent destruction and recreation, but, rather, for remaining in scene, possibly on another layer, when it might be frequently referenced, due to the rather intense overhead Unity requires to instantiate GameObjects.
Comes with a 12 page PDF manual describing all scripts with which the user should be interacting with.