The Global Database
At the heart of HookUI lies the HookUI Database. This is a ScriptableObject that acts as the single source of truth for all identifiers in your project.
Why a Database?
In traditional Unity development, you might reference UI screens by:
GameObjectreferences (Fragile: break if object is destroyed).- String literals
"MainMenu"(Error-prone: typos capable). - Enums (Rigid: requires recompilation to add a new screen).
HookUI solves this with String-based IDs managed by a dedicated Editor. This gives you the flexibility of strings with the safety of a dropdown menu.
Structure
Under the hood, the database (HookUIDatabase.cs) is a ScriptableObject holding four groupings:
ViewCategories: Represent full screens or modal popups (e.g.,MainMenu,Inventory,Popup_Error).ButtonCategories: Represent actions that trigger navigation (e.g.,Btn_Play,Btn_Back,Btn_Close).ComponentCategories: IDs for reusableHookUIComponentinstances (see below).SignalIDs: Represent global events (e.g.,OnGameStart,OnPlayerDeath).
ViewCategories, ButtonCategories, and ComponentCategories are each a List<CategoryGroup>, where a CategoryGroup is just a CategoryName plus a flat List<string> Items. This is how Views, Buttons, and Components get organized into named categories (e.g., General, HUD, Popups).
SignalIDs, by contrast, is a single flat List<string> — signals aren't grouped into categories at all, they're just a plain list of ID strings.
The Components grouping
ComponentCategories backs the reusable HookUIComponent system — each component is identified by a Category/ID pair, the same way Views and Buttons are. If you haven't run into HookUIComponent yet, see the Components page for how it's used.
Where it lives
The database is a ScriptableObject singleton, accessed via HookUIDatabase.Instance. It's auto-loaded with Resources.Load<HookUIDatabase>("HookUI/HookUI_Database"), and if no asset exists yet, one is auto-created at Assets/Resources/HookUI/HookUI_Database.asset.
You edit it through Tools > HookUI > Dashboard > ID Database, which has separate sub-tabs for Views, Buttons, Components, and Signals.
Multi-Database Support
HookUI supports Modular Architectures. You can split your data into multiple database files.
- Primary Database: Your main project data, located at
Assets/Resources/HookUI/HookUI_Database.asset. Only this one is editable via the Dashboard. - External Databases: Any
HookUIDatabaseasset found in anyResourcesfolder (e.g., inside a Unity Package or a different module).
How it works: The system automatically detects these external databases at runtime/editor-time and merges them into the list of available IDs. This allows you to install 3rd party modules that come with their own HookUI screens (like our Demo Lab) without polluting your main project file.
Usage in Code
You rarely access the database directly. Instead, you use the components (HookView, HookButton) which have custom Property Drawers that query this database to show you the dropdowns.
If you DO need to query it from code:
// Check if a View ID exists
bool exists = HookUIDatabase.Instance.ViewIDs.Contains("MyViewID");
// Get all IDs in a category
List<string> hudButtons = HookUIDatabase.Instance.GetItems(HookUIIDType.Button, "HUD");