Skip to main content

Performance Tips

UI is often a silent performance killer in Unity. HookUI does a lot of optimization for you, but you can help it.

1. Canvas Splitting

Don't put everything under one massive Canvas.

  • Dynamic UI: (Health bars, damage numbers) -> Separate Canvas.
  • Static UI: (Backgrounds, Borders) -> Separate Canvas.
  • HookUI Flows: HookUI handles HookViews efficiently by disabling their Canvas Component when hidden. This prevents Unity from re-calculating the layout for hidden screens.

2. Graphic Raycasters

Every GraphicRaycaster on screen has a cost every frame (or every input).

  • HookUI Automatic: HookView automatically disables the GraphicRaycaster when the view is hidden.
  • Manual: If you have complex nesting, ensure you don't have Raycasters on objects that don't need interaction (like Images acting as backgrounds).

3. ID Lookups

HookUI uses string hashes for lookups internally in some places, but string comparisons in others.

  • Cached: The database is loaded into memory. Lookups are fast (Dictionary or Hash based).
  • Avoid: Don't call HookUIDatabase.GetItems() every frame. Cache the result in Start().