Disable Dialogue System Input During Game Pause

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lcn_mc
Posts: 57
Joined: Wed Jun 29, 2022 1:56 pm

Disable Dialogue System Input During Game Pause

Post by lcn_mc »

Hello, all.

Currently, my pause system works by listening for a key press, which then opens activates a Canvas Game Object that has various images and buttons as child Game Objects. (e.g.: Return to Game, Quit Game, etc.) The intent is that when the pause menu is open, the Dialogue System does not listen for/act on player input, but it's fine if things like animated dialogue portraits and such continue playing.

I've tried a variety of things (found in other forum threads and with PlayMaker), but no matter what I try, I can't seem to get the Dialogue System to ignore input when the game is in the 'pause' state. (The 'failure mode' here is that, while the pause menu is up, the player can still advance conversations by hitting the key I have mapped to a general 'interact' action.)

Here is what I've tried (and what hasn't worked):

* Using the PlayMaker Action 'Pause' that's part of the Dialogue System set of PlayMaker actions. (It didn't seem to do anything.)
* Trying to use the PlayMaker Action 'EnableBehavior' to turn off the InputDeviceManager behavior on the main Dialogue Manager Game Object.
* Adding a script (whenever the Pause Menu is active) to the Dialogue Manager that contains the following:
  • 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).
If anyone has any suggestions on how to tell the Dialogue Manager to stop listening for or capturing input entirely during specific situations (such as when a pause menu is open), please let me know.

Thanks for the help!
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Disable Dialogue System Input During Game Pause

Post by Tony Li »

lcn_mc
Posts: 57
Joined: Wed Jun 29, 2022 1:56 pm

Re: Disable Dialogue System Input During Game Pause

Post by lcn_mc »

Tony,

Thanks for the quick reply. I did indeed use the suggestions from that page in a script that was dynamically added to / removed from the Dialogue Manager when the Pause Menu was activated / deactivated before I made the post.

But, after seeing your reply and rechecking the script, I found that I forgot to add the 'using PixelCrushers.DialogueSystem;' at the start of the script, and adding that back in seems to have gotten it working. There look to be some oddities around dynamic portraits when the game is in a paused state, but I'll tinker with it more tomorrow and let you know if I run into any issues.

Appreciate the assistance here, as always.
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Disable Dialogue System Input During Game Pause

Post by Tony Li »

Glad to help!
lcn_mc
Posts: 57
Joined: Wed Jun 29, 2022 1:56 pm

Re: Disable Dialogue System Input During Game Pause

Post by lcn_mc »

Tony,

Ok, I've fiddled with it a little more and have gotten the pause working, but I did find what seems like an odd bug: The Input Freeze for the Dialogue System won't trigger, even if the script with the 'PixelCrushers.UIButtonKeyTrigger.monitorInput = false;' line is attached to the Dialogue Manager Game Object unless I first use my mouse to click somewhere in the active scene.

Here's a play-by-play example:

1. I hit 'P' to pause the game. (This is just a temporary hotkey I've setup.)
2. My pause system adds a simple, temporary script to the Dialogue Manager Game Object with the following lines of code:
  • PixelCrushers.UIPanel.monitorSelection = false;
  • PixelCrushers.UIButtonKeyTrigger.monitorInput = false;
3. If I press spacebar, which is my current 'advance dialogue' hotkey, the conversation will continue as normal.
4. If I mouse click anywhere in the active scene and then try to hit spacebar, the spacebar will no longer advance the conversation.

So, it seems like the input pause doesn't come into effect unless I mouse click anywhere in the active scene.

I can probably work around the bug (such as by trying to introduce an artificial mouse click or something), but I'd be interested to hear your thoughts. Thanks.
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Disable Dialogue System Input During Game Pause

Post by Tony Li »

Hi,

It's not a bug. It's how Unity UI's EventSystem works. If you press the EventSystem's Submit input (by default mapped to Space and Enter), it will click the currently-selected button.

In step #2 (PixelCrushers.UIPanel.monitorSelection = false; etc.), add this to deselect the continue button:

Code: Select all

UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null);
Alternatively, if you want to be able to navigate your own pause menu using keyboard or joystick, pass one of its buttons to SetSelectedGameObject() instead of null.
lcn_mc
Posts: 57
Joined: Wed Jun 29, 2022 1:56 pm

Re: Disable Dialogue System Input During Game Pause

Post by lcn_mc »

Tony,

That seems to have done it. Many thanks, as I certainly would've not thought to look into the Unity UI Event System.

I'll tweak it a bit more, but otherwise I think (or hope) it's behaving as I would want with this fix.

Thanks again!
User avatar
Tony Li
Posts: 21033
Joined: Thu Jul 18, 2013 1:27 pm

Re: Disable Dialogue System Input During Game Pause

Post by Tony Li »

Glad to help!
Post Reply