How To: Show PC Subtitle Except When Same As Menu

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

How To: Show PC Subtitle Except When Same As Menu

Post by Tony Li »

By default, conversations show player nodes in response menus and not as subtitles.

Related: How To: Bypass Response Menu When Player Has Only One Choice

Sometimes you'll write the player's short paraphrase response in the Menu Text field and an expanded subtitle version in the Dialogue Text field. To show both of these, inspect the Dialogue Manager GameObject. In the Display Settings > Subtitle Settings section, tick Show PC Subtitles During Line and UNtick Skip PC Subtitle After Response Menu.

If you want to skip the subtitle if the text is the same as the menu text, add a script like this to the Dialogue Manager. It makes use of the OnConversationLine script message.

SkipPlayerSubtitleIfSameAsMenu.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SkipPlayerSubtitleIfSameAsMenu : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle.speakerInfo.isPlayer && subtitle.dialogueEntry.subtitleText == subtitle.dialogueEntry.responseButtonText)
        {
            subtitle.formattedText.text = string.Empty;
        }
    }
}
Note: The player node's Sequence will still play (e.g., for voiceover audio). If you don't want it to play, set:

Code: Select all

subtitle.sequence = "Continue()";
Post Reply