[HOWTO] How To: Pause Dialogue In Pause Menu
Posted: Tue Apr 13, 2021 11:32 am
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:
3. When closing the pause menu, use code similar to this:
Your pause menu should grab Unity UI input focus. Example:
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:
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.
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.
Code: Select all
public void OpenPauseMenu()
{
//... (your code here to open pause menu) ...
EventSystem.current.SetSelectedGameObject(firstPauseMenuButton);
}
- 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.