Skip to main content

Multi-Database Support

This advanced feature allows HookUI to aggregate IDs from multiple HookUIDatabase.asset files, so you're not forced to keep every View/Button/Signal ID in one monolithic asset.

Why you'd want more than one database​

  • Shared/base + project-specific: a common package (a shared UI kit reused across projects) ships its own database with its own View/Button IDs, and each project adds a second, project-specific database on top without editing the shared one.
  • Modular features: a "Store" module you import into multiple projects, with its own Views (StoreMain, StoreItem) that shouldn't have to live in your main global database.
  • Per-DLC / per-module content: a database that only exists in the project when that optional content module is installed — its IDs simply aren't there (and don't need to be) when the module is absent.
  • Third-party assets: importing a HookUI-compatible asset pack shouldn't force you to hand-copy its IDs into your own database.

How merging works​

Any HookUIDatabase asset that exists anywhere under any Resources/ folder in the project is auto-discovered and merged in — not just the primary one at Assets/Resources/HookUI/HookUI_Database.asset.

Concretely, HookUIDatabase.LoadExternalDatabases() (in Runtime/Scripts/Scriptable Objects/HookUIDatabase.cs) calls:

Resources.LoadAll<HookUIDatabase>("")

Resources.LoadAll<T>("") scans every Resources folder in the project (there can be several, at any depth, in any package or Assets subfolder) and returns every HookUIDatabase asset it finds. Every one of those except this itself gets added to an internal _externalDatabases list. This runs in OnEnable(), and again whenever HookUIDatabase.Instance is accessed, so newly-added external databases are picked up without any manual registration step.

How to Use​

  1. Create Custom Database: Right-click in any Resources folder (or subfolder like Resources/HookUI): Create > HookUI > Database.
  2. Populate: Add your Views, Buttons, Components, and Signals to this new asset.
  3. Done: HookUI automatically finds this asset at runtime (and in the Editor) and merges its IDs into the global set — no wiring, no reference to assign anywhere.

Note: External databases are read-only in the Dashboard Settings to prevent accidental modification of package data. You must edit the asset file directly or switch your focus if you want to modify them.

GetItems vs GetLocalItems​

HookUIDatabase exposes both a merged view and a local-only view of its data:

public List<string> GetItems(HookUIIDType type, string category)
public List<string> GetLocalItems(HookUIIDType type, string category)
  • GetLocalItems(type, category) returns only the items defined in this database asset's own category group — it never looks at _externalDatabases.
  • GetItems(type, category) returns this database's local items plus the same category's items from every external database it has discovered, de-duplicated (.Distinct()).

The same local-vs-merged split applies to the other collection properties (ViewIDs, ButtonIDs, ComponentIDs, Categories, etc.) — each has a private recursive collector that walks _externalDatabases and guards against cycles (a database that somehow ends up referencing itself, directly or transitively, won't infinite-loop).

Use GetItems/the *IDs properties when you want "everything available to this project" (e.g. populating an ID dropdown in the editor). Reach for GetLocalItems only when you specifically need to know what one particular database asset defines on its own, independent of what else is merged in.