[HOWTO] How To: Pause Dialogue In Pause Menu

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 20731
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Pause Dialogue In Pause Menu

Post by Tony Li »

To pause the Dialogue System when the player brings up a (non-Dialogue System) pause menu or other UI window:

1. Set the Dialogue Manager's Other Settings > Dialogue Time to Realtime. (Alternatively, if you need it to be Gameplay, set Time.timeScale=0 when you open your pause menu or inventory.)

2. When opening your pause menu, use code similar to this:

Code: Select all

PixelCrushers.UIPanel.monitorSelection = false; // Don't allow dialogue UI to steal back input focus.
PixelCrushers.UIButtonKeyTrigger.monitorInput = false; // Disable hotkeys.
PixelCrushers.DialogueSystem.DialogueManager.Pause(); // Stop DS timers (e.g., sequencer commands).
playerSelector.enabled = false; // Example: Disable player's Selector component.
3. When closing the pause menu, use code similar to this:

Code: Select all

PixelCrushers.UIPanel.monitorSelection = true; // Allow dialogue UI to steal back input focus again.
PixelCrushers.UIButtonKeyTrigger.monitorInput = true; // Re-enable hotkeys.
PixelCrushers.DialogueSystem.DialogueManager.Unpause(); // Resume DS timers (e.g., sequencer commands).
playerSelector.enabled = true; // Example: Re-enable player's Selector component.
Your pause menu should grab Unity UI input focus. Example:

Code: Select all

public void OpenPauseMenu()
{
    //... (your code here to open pause menu) ...
    EventSystem.current.SetSelectedGameObject(firstPauseMenuButton);
}
Note: If you're writing your own pause menu, you can make it a subclass of PixelCrushers.UIPanel and call its Open() and Close() methods. Then you can omit PixelCrushers.UIPanel.monitorSelection in the code above. UIPanel has these features:
  • Can play open & close animations.
  • Can ensure that some selectable (e.g., UI Button) in the panel is focused so the player can always navigate using joystick or keyboard.
Post Reply