Skip to main content

HookUIComponent

Not everything that shows and hides is a full screen. A toast, a tooltip, an optional side panel, a sub-widget inside a bigger HookView — these don't need their own navigation entry, but they still need clean show/hide behavior. That's what HookUIComponent is for.

It uses the same [HookUIID] Category/ID pattern as the rest of HookUI, registered under the database's "Components" category — see The Database.

Inspector Properties

Identity

  • Category: Grouping for this component (e.g., "HUD", "Popups").
  • ID: Unique identifier string.

Behavior

  • Execution Mode:
    • Manual: nothing happens automatically — you call PlayShow() / PlayHide() yourself.
    • SyncWithParent: the component auto-subscribes to the nearest parent HookView's OnShowStarted / OnHideStarted events, so it shows and hides in lockstep with its parent screen automatically.

Sequencing

  • Show Delay: seconds to wait before actually playing the show. Useful for staggered reveal effects.
  • Hide Delay: seconds to wait before actually playing the hide.

Startup

  • Hide On Awake: if true, the component starts hidden.

Code API

public class HookUIComponent : MonoBehaviour
{
public void PlayShow(); // Plays the (optionally delayed) show animation
public void PlayHide(); // Plays the (optionally delayed) hide animation
public void ImmediateShow(); // Shows instantly, no animation/delay
public void ImmediateHide(); // Hides instantly, no animation/delay
}

If a HookAnimatorComponent is attached, PlayShow/PlayHide drive its PlayShow()/PlayHide() coroutines. Without one, ImmediateShow/ImmediateHide are no-ops beyond the animator call, so pair HookUIComponent with a HookAnimatorComponent if you want an actual animated transition.

:::danger Don't trap your own navigation buttons Never set Execution Mode = Manual with Hide On Awake = true on a sub-panel that holds a screen's actual navigation buttons.

With Manual mode, nothing calls PlayShow() for you — the component only shows when something explicitly tells it to. If Hide On Awake is also on, the panel starts hidden and stays hidden forever, because the buttons that could reveal it (including whatever button was supposed to open the panel in the first place) are trapped behind the very panel that's hiding them.

Only use Manual + Hide On Awake together on panels holding genuinely optional content — things the player can permanently miss without getting stuck (a tip banner, an optional promo panel). If the panel gates access to navigation, either use SyncWithParent, turn off Hide On Awake, or make sure something outside the panel can still call PlayShow() on it. :::