Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Tentakero
Posts: 48
Joined: Wed Sep 23, 2020 12:36 pm

Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tentakero »

Hello. I'm having a bit of trouble with getting the dialogue panel to refocus after starting or ending a conversation.

The Always Auto Focus option works but highlights the first response option automatically. Is there any way to get the dialogue system to refocus itself if it detects input from a joystick or a keyboard press?

I'm not entirely sure how to link rewired to the dialogue system through the input checks. This is what my DialogueManager looks like at the moment.

Image

And this is what the Rewired side of things is looking like

Image

Am I supposed to go by the "Left Stick X" axis naming or by the UIHorizontal action name when it comes to the Dialogue Manager's side of things? Thanks in advance for any help on this.
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tony Li »

Use Rewired action names (e.g., UIHorizontal). If you don't have Rewired actions that are specific to the joystick, you'll either need to add them to your Rewired Input Manager or use key codes:

rewiredInputDeviceManager.png
rewiredInputDeviceManager.png (23.86 KiB) Viewed 1034 times

You can mix and match button (action) names and key codes.
Tentakero
Posts: 48
Joined: Wed Sep 23, 2020 12:36 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tentakero »

Ah ok I see. It seems like the Dialogue Manager is properly switching between input modes but my problem is coming from the EventSystem. I'm enabling a small name input field for the player and when closing it, the dialogue manager doesn't regain focus with the Rewired Event System.

Is the simplest way to fix this just adding something like

Code: Select all

EventSystem.current.SetSelectedGameObject(//DialogueManagerUIComponenthere?)
Or would there be a better way to go about restoring focus to the dialogue system?
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tony Li »

Hi,

If the Input Device Manager's Input Device is set to Joystick or Keyboard, or if Always Auto Focus is checked, then when a conversation is active the dialogue UI will try to steal focus.

If you open a different input field while a conversation is open, your input field shouldn't be able to retain focus. If it does retain focus, then one of these things is probably happening:

1. The Input Device Manager's Input Device is set to Mouse.

2. Or, on the dialogue UI's active panel (subtitle panel or menu panel) the Focus Check Frequency is set to zero.

3. Or you've set UIPanel.monitorSelection=false in C# code.

If you've verified that the Input Device is set to Joystick or Keyboard, and that Focus check Frequency is greater than zero, you should see that your input field can't keep focus. This is good. The next step is to set PixelCrushers.UIPanel.monitorSelection = false when opening your input field. When closing your input field, set it back to true.
Tentakero
Posts: 48
Joined: Wed Sep 23, 2020 12:36 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tentakero »

Thanks for the info. I've tried these solutions out but they don't seem to be working.

Something I did notice is that even without the InputField, the Event System sometimes starts the scene with nothing selected, and the Dialogue Manager never steals focus for itself. The InputManager is switching properly between Mouse, Keyboard and Joystick, but for some reason, the panel never gains focus when in Keyboard or Joystick mode.

Focus Frequency check is 0.2 on all applicable panels by default I believe, since I based it off of one of the sample templates.

Is this what the Auto Focus bool is meant to handle? Also, I noticed that the Input Device Manager has OnUse methods, it's probably also possible to use that to call a refocus whenever joystick or keyboard is detected right?
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tony Li »

Hi,

The Always Auto Focus checkbox tells the Dialogue System to keep navigation focus on the dialogue UI even if the Input Device Manager has switched to Mouse mode (e.g., by moving the mouse).

The OnUseMouse/Joystick/Keyboard() UnityEvents don't do anything on their own. They're just event hooks in case you want to do something extra when the Input Device Manager switches to Mouse, Joystick, or Keyboard mode.

Can you send a reproduction project to tony (at) pixelcrushers.com?
Tentakero
Posts: 48
Joined: Wed Sep 23, 2020 12:36 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tentakero »

I can't send a full repro project but I may be able to do a test build that shows the issue. If that's ok I'll go ahead and send it.
User avatar
Tony Li
Posts: 22149
Joined: Thu Jul 18, 2013 1:27 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tony Li »

Hi,

Sure, anything that reproduces the issue is great.
Tentakero
Posts: 48
Joined: Wed Sep 23, 2020 12:36 pm

Re: Refocusing Dialogue or Response Panel with Keyboard or Joystick? (Rewired)

Post by Tentakero »

Ok, I'll be sending that shortly. While waiting for the response, I had a small breakthrough!

I managed to get it working in a bit of a roundabout way using the OnJoystick and OnKeyboard event hooks. The panel I'm using always requires the continue button, and when it loses focus, it seems to not pick it back up automatically.

Code: Select all

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PixelCrushers.DialogueSystem;
using PixelCrushers;
using UnityEngine.EventSystems;

public class DialogueRefocuser : MonoBehaviour
{
    public void RefocusDialoguePanel()
    {
        if(DialogueManager.isConversationActive)
        {
            StandardUIContinueButtonFastForward continueButton = GetComponentInChildren<StandardUIContinueButtonFastForward>(true);
            if(continueButton.isActiveAndEnabled)
            {
                EventSystem.current.SetSelectedGameObject(continueButton.gameObject);
                Debug.Log("Refocus Attempt: Focused Continue Button");
            }
            else
            {
                EventSystem.current.SetSelectedGameObject(GetComponentInChildren<StandardUIResponseButton>().gameObject);
                Debug.Log("Refocus Attempt: Focused Menu Selectable");
            }
        }
        else
        {
            Debug.Log("Refocus Attempt: Conversation not active");
        }
    }
}
I need to refactor it to clean it a little bit but any simpler or more efficient ways to handle this are much appreciated!
Post Reply