How to customize Subtitle Panel?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Housein
Posts: 1
Joined: Wed Oct 21, 2020 8:16 am

How to customize Subtitle Panel?

Post by Housein »

I want to Add a text field and a button for every subtitles. they could be shown/hidden by a toggle button in runtime.
Is it possible in Dialogue System?
Standard UI Subtitle Panel component has "Subtitle Text" Field in a wrapper class.
I wonder what is the best way to have and extra Text Field and a Button to subtitles and responds as well.
(I'm not sure if it's the right way to ask these kind of questions here)
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to customize Subtitle Panel?

Post by Tony Li »

Hi,

You can just add them to the subtitle panel and response menu panel. As long as they're a while of the panel, they'll appear when the panel is activated. You can set their values using OnConversationLine and OnConversationResponseMenu methods on the Dialogue Manager. (More info: Script Messages) Example:

Code: Select all

public class ExtraDialogueFields : MonoBehaviour
{
    public bool showExtraFields;
    public Text extraTextField;
    public Button extraButton;
    
    void OnConversationLine(Subtitle subtitle)
    {
        extraButton.gameObject.SetActive(extraButton);
        extraTextField.gameObject.SetActive(showExtraFields);
        extraTextField.text = "Subtitle length: " + subtitle.formattedText.text.Length);
    }
    
    void OnConversationResponseMenu(Response[] responses)
    {
        // (Maybe some similar code here)
    }
}
Alternatively, you can make a subclass of StandardUISubtitlePanel and StandardUIMenuPanel. Override their ShowSubtitle and ShowResponses methods. If you're using the evaluation version, the base class is in a DLL, but the API references are here:
Post Reply