Show PC Subtitles During Line - Disable on certain responses

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
apocrypha1
Posts: 6
Joined: Mon Aug 14, 2023 6:53 pm

Show PC Subtitles During Line - Disable on certain responses

Post by apocrypha1 »

Hi! I've been trying to get the following behaviour to work for a bit now with no results, so thought I might a well ask here.

Basically, I want the setting Show PC Subtitles During Line to be activated UNLESS the player clicks on a response with a generic line, such as "Continue.", "End." ETC.

If the response button the player clicks on does have a text component with that sort of string, I want to temporarily disable the Show PC Subtitles During Line -setting. Then, if the next response button the player clicks on is something other than this sort of generic response, I want to re-enable that setting, for a smoother look.

I've tried modifying the Response Button Template's OnClick Event with this additional behaviour but I'm having difficulty in achieving this result. If it helps, I'm using TextMeshPro and a variant of the Scrolling Dialogue UI Prefab.

Thanks a lot in advance!
User avatar
Tony Li
Posts: 22114
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show PC Subtitles During Line - Disable on certain responses

Post by Tony Li »

Hi,

You can add a script like this to the Dialogue Manager:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class BypassPCSubtitleOnCertainResponses : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle.speakerInfo.IsPlayer && (subtitle.formattedText.text == "Continue" || subtitle.formattedText.text == "End"))
        {
            subtitle.sequence = "Continue()";
        }
    }
}
This will bypass PC subtitles if the response text is "Continue" or "End". It relies on the OnConversationLine script message.
apocrypha1
Posts: 6
Joined: Mon Aug 14, 2023 6:53 pm

Re: Show PC Subtitles During Line - Disable on certain responses

Post by apocrypha1 »

Super simple and elegant, thank you very much! Exactly what I was looking for.
User avatar
Tony Li
Posts: 22114
Joined: Thu Jul 18, 2013 1:27 pm

Re: Show PC Subtitles During Line - Disable on certain responses

Post by Tony Li »

Glad to help!
Post Reply