Page 1 of 1

How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Thu Jul 23, 2020 7:12 am
by Sharkbowl
Hi Pixel Crushers team,

I hope all is well, I was wondering if there is a way to hide the conversation UI and disable any input such as the skip dialogue feature when pressing the ESC key using C#.

I'm trying to achieve this when I pause the game, but couldn't find any methods for this in the DialogueManager script.

Many thanks,
SB :D

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Thu Jul 23, 2020 8:51 am
by Tony Li
Hi,

The easiest way is to disable the dialogue UI's Canvas and the cancel input.

To disable the dialogue UI's canvas:

Code: Select all

var dialogueUI = DialogueManager.dialogueUI as AbstractDialogueUI;
dialogueUI.GetComponentInParent<Canvas>().enabled = false;
You might want to entirely disable the cancel input and just use the continue button to allow the player to skip ahead. To do this, inspect the Dialogue Manager. In Input Settings > Cancel Subtitle Input and Cancel Conversation Input, set the Key to KeyCode.None and the Button to a blank string. If you only want to do it when pausing:

Code: Select all

var inputSettings = DialogueManager.displaySettings.inputSettings;
inputSettings.cancel.key = KeyCode.none;
inputSettings.cancel.button = string.Empty;
inputSettings.cancelConversation.key = KeyCode.none;
inputSettings.cancelConversation.button = string.Empty;

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Sun Jul 26, 2020 10:46 am
by Sharkbowl
Hi Tony,

Amazing! Thanks so much for the help. I've got it working exactly how I wanted. :D

Thanks,
SB :D

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Sun Jul 26, 2020 11:30 am
by Tony Li
Great! Glad I could help.

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Mon Aug 24, 2020 9:21 am
by Sharkbowl
Hi Tony,

I hope all is well, I'm trying to set up the skip button for both keyboard and joystick. However, what is happening is that one always seems to override the other.

For instance, below is the code I'm using to trigger this. However, I notice that the joystick overrides the keyboard in this example and if I were to switch them around (joystick above keyboard) then it has the opposite effect. I've tried using the || operator but I get the following error message. "Operator '||' cannot be applied to operands of type 'KeyCode' "

Code: Select all

var inputSettings = DialogueManager.displaySettings.inputSettings;
            inputSettings.cancel.key = KeyCode.G;
            inputSettings.cancelConversation.key = KeyCode.G;
            inputSettings.cancel.key = KeyCode.JoystickButton3;
            inputSettings.cancelConversation.key = KeyCode.JoystickButton3;
        }
If you could shed some light on how to resolve this, I'd greatly appreciate it.

Thanks,
SB :D

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Mon Aug 24, 2020 10:54 am
by Tony Li
Hi,

There are two ways to skip: the Dialogue Manager's cancel subtitle input (as in your post) or using a continue button.

One advantage of the continue button is that you can add a "fast forward" component that causes it to only fast-forward the typewriter (if you're using one and it's still typing) instead of skipping ahead immediately. You can bind one or more hotkeys using UI Button Key Trigger components.

The cancel inputs (key and buttonName) can only take one value each. In the Input Manager (Edit > Project Settings > Input), try defining an input named something like "CancelSubtitle" with positive button set to "g" and alt positive button set to "joystick button 3". Then use this:

Code: Select all

inputSettings.cancel.buttonName = "CancelSubtitle";

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Mon Aug 24, 2020 1:29 pm
by Sharkbowl
Hi Tony,

I'm pretty happy with the way it's skipping at the moment (skipping to the next text). Thank you very much, this is now working and detecting both keyboard and joystick!

Many thanks,
SB :D

Re: How to hide conversation UI & disable input (skip dialogue) in C#

Posted: Mon Aug 24, 2020 2:06 pm
by Tony Li
Happy to help!