Page 1 of 1

How To: Show PC Subtitle Except When Same As Menu

Posted: Sat Nov 21, 2020 4:05 pm
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()";