A Few Questions about the Response Menu

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Lavitsef
Posts: 5
Joined: Thu Jun 15, 2023 1:13 am

A Few Questions about the Response Menu

Post by Lavitsef »

Hi! I recently encountered several questions.
1. I noticed that to make the responses show up, I have to click at the screen once. Maybe it's due to some settings? Is there any way to let all the responses automatically show up in like 0.5s after the last entry is shown?
2. Is there any way to hide a response? For example if a response entry's text is empty, I want it not to show up at all. I tried to untick "include invalid entry" but that doesn't seem to hide empty response.
3. How does timeout work for responses? For example, after an entry, there are 3 responses. If the player doesn't answer in 3 secounds, then the entry goes into a different node saying something like "you lose." I'm having trouble actually constructing this.
4. My continue button key trigger is set to "space". I noticed that sometimes when I press space the continue button gets fired twice. Is this problem possibly connected to any settings here?
Thank you for your help in advance!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: A Few Questions about the Response Menu

Post by Tony Li »

Hi,
Lavitsef wrote: Fri Dec 29, 2023 10:31 pm1. I noticed that to make the responses show up, I have to click at the screen once. Maybe it's due to some settings? Is there any way to let all the responses automatically show up in like 0.5s after the last entry is shown?
Inspect the Dialogue Manager GameObject. Set Display Settings > Subtitle Settings > Continue Button to Never. Set Subtitle Chars Per Second to 50 and Min Subtitle Seconds to 0.5.
Lavitsef wrote: Fri Dec 29, 2023 10:31 pm2. Is there any way to hide a response?
Set the response entry's Conditions. See: Conversation Conditions Tutorial.
Lavitsef wrote: Fri Dec 29, 2023 10:31 pm3. How does timeout work for responses? For example, after an entry, there are 3 responses. If the player doesn't answer in 3 secounds, then the entry goes into a different node saying something like "you lose."
Set the Dialogue Manager's Display Settings > Input Settings > Response Timeout to 3. Set Response Timeout Action dropdown. If none of the built-in dropdown options fit your needs, select Custom and assign a C# method to DialogueManager.customResponseTimeoutHandler. Some example code is in this post.
Lavitsef wrote: Fri Dec 29, 2023 10:31 pm4. My continue button key trigger is set to "space". I noticed that sometimes when I press space the continue button gets fired twice. Is this problem possibly connected to any settings here?
Remove the UI Button Key Trigger. The Space key is already mapped to the EventSystem's "Submit" input, which means the EventSystem will already click the currently-selected button whenever you press Space. There's no need to map a UI Button Key Trigger component to also click it. To ensure that the continue button is selected while showing subtitles, tick the Dialogue Manager's Input Device Manager component > Always Auto Focus checkbox.
Lavitsef
Posts: 5
Joined: Thu Jun 15, 2023 1:13 am

Re: A Few Questions about the Response Menu

Post by Lavitsef »

That worked perfectly! Thank you so much.

Though I still have a small question regarding the Continue Button. I removed the UI Button Key Trigger and ticked Always Auto Focus checkbox, but I noticed that I still need to click once before I can use Space key. Also when Always Auto Focus is checked, whenever there is a response, the first response gets selected automatically, but I only want the continue button to be auto focused while leave all the responses unfocused by default. Is there any way to achieve that?

Also I've got some questions regarding localizing variables (sorry for dumping so many questions at once)

What is the best way to change an actor's name to "???" before they introduce themselves to the player? Since in the actor's field there could be multiple display names for different languages, does that mean I have to set all display names (display name en, display name fr, etc) into "???" manually?

And is it possible to localize text variables? I installed i2 localization plugin as well, is it possible to use it to localize variables in Dialogue System?

Thanks in advance again.
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: A Few Questions about the Response Menu

Post by Tony Li »

Hi,
Lavitsef wrote: Sat Dec 30, 2023 6:52 pmThough I still have a small question regarding the Continue Button. I removed the UI Button Key Trigger and ticked Always Auto Focus checkbox, but I noticed that I still need to click once before I can use Space key. Also when Always Auto Focus is checked, whenever there is a response, the first response gets selected automatically, but I only want the continue button to be auto focused while leave all the responses unfocused by default. Is there any way to achieve that?
Untick the Always Auto Focus checkbox in that case. Make sure your continue button is assigned to the subtitle panel's Standard UI Subtitle Panel component > First Selected field. Keep an inspector on the EventSystem

If you're playing in the Unity editor's play mode, is your Game view's "Play" dropdown set to "Play Focused", "Play Maximized", or "Play Unfocused"? If it's set to Play Unfocused, change it to Play Focused.

If that doesn't help, add a script like this to the subtitle panel:

KeepContinueButtonSelected.cs

Code: Select all

using PixelCrushers.DialogueSystem;
using UnityEngine;
using UnityEngine.EventSystems;

public class KeepContinueButtonSelected : MonoBehaviour
{
    private StandardUISubtitlePanel panel;

    private void Awake()
    {
        panel = GetComponent<StandardUISubtitlePanel>();
    }

    private void Update()
    {
        if (panel.hasFocus) EventSystem.current.SetSelectedGameObject(panel.continueButton.gameObject);
    }
}
Lavitsef wrote: Sat Dec 30, 2023 6:52 pmWhat is the best way to change an actor's name to "???" before they introduce themselves to the player? Since in the actor's field there could be multiple display names for different languages, does that mean I have to set all display names (display name en, display name fr, etc) into "???" manually?
You can use a script method. You can also register this script method with Lua if you want to use it inside conversations. For example:
  • Set "Display Name en", "Display Name fr", etc., all to "???".
  • Then add custom fields named "Real Display Name en", "Real Display Name fr", etc., and set them to the names to use after the NPC has introduced itself.
  • Write a script method to copy the "Real Display Name **" values to the "Display Name **" fields, such as:

    Code: Select all

    public void IntroduceActor(string actorName)
    {
        var actor = DialogueManager.masterDatabase.GetActor(actorName);
        if (actor == null) return;
    
        // Copy "Real Display Name **" fields to "Display Name **" Lua fields:
        foreach (var field in actor.fields)
        {
            if (field.title.StartsWith("Display Name "))
            {
                DialogueLua.SetActorField(actorName, field.title, $"Real {field.title}");
            }
        }
    
        // Update current conversation's UI:
        var newDisplayName = DialogueLua.GetLocalizedActorField(actorName, "Display Name").asString;
        DialogueManager.ChangeActorName(actorName, newDisplayName);
    }
Lavitsef wrote: Sat Dec 30, 2023 6:52 pmAnd is it possible to localize text variables? I installed i2 localization plugin as well, is it possible to use it to localize variables in Dialogue System?
The Dialogue System's i2 Localization integration doesn't localize Dialogue System variables. If the variable's value never changes, you can register a script method with Lua that returns an i2 term's value. You can then use [lua(code)] markup tags to show i2 terms in your dialogue text.
Lavitsef
Posts: 5
Joined: Thu Jun 15, 2023 1:13 am

Re: A Few Questions about the Response Menu

Post by Lavitsef »

The scripts worked like a charm. Thank you so much!!
User avatar
Tony Li
Posts: 21678
Joined: Thu Jul 18, 2013 1:27 pm

Re: A Few Questions about the Response Menu

Post by Tony Li »

Glad to help!
Post Reply