Skip to main content

Unity Events Integration

HookUI is designed to handle users navigating MENUS. But menus are just the gateway to the GAME.

The HookUI View Inspector​

Every HookView has four standard events exposed in the Inspector:

  1. OnShowStarted: Best for pausing the game (Time.timeScale = 0).
  2. OnShowFinished: Best for enabling input.
  3. OnHideStarted: Best for disabling input.
  4. OnHideFinished: Best for unpausing (Time.timeScale = 1).

Example: Pause Menu​

  1. Create View: ID PauseMenu.
  2. OnShowStarted: Drag your GameManager script and call GameManager.PauseGame().
  3. OnHideFinished: Drag your GameManager script and call GameManager.ResumeGame().

Connecting Buttons to Logic​

Buttons are not just for navigation.

  • Play Button: Needs to load a scene.
  • Settings Button: Just navigates.
  • Save Button: Needs to write to disk.

For the Play Button (which navigates to a Loading Screen), you can attach a script to the same GameObject:

public class SceneLoader : MonoBehaviour
{
private HookButton _btn;
void Awake() {
_btn = GetComponent<HookButton>();
_btn.OnClick.AddListener(LoadLevel);
}

void LoadLevel() {
SceneManager.LoadScene("Level1");
}
}

Or just use the OnClick event in the Inspector directly.