Hide Subtitle panel on empty nodes

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Kopire
Posts: 6
Joined: Thu Jun 29, 2023 1:44 pm

Hide Subtitle panel on empty nodes

Post by Kopire »

Hi.

We've been trying to find a solution for this for a while, and couldn't come with any solution that wouldnt require us to use "HidePanel();" in every node that doesnt have text in it.

So the behaviours we want are :
  • If a character starts talking, the subtitle panel shows up.
  • If there is an empty node between two nodes that contain text, we want the subtitle panel to hide itself.
For exemple :
  • Node 1 : Character X : Hi, my name is Potato
  • Node 2 : Only contains sequences and scripts. Let's say that I want to make Character X move in the scene.
  • Node 3 : Character Y : Hello Potato, my name is Apple!
So I want the subtitle panel to show up on node 1 and 3, but hidden during node 2

I see 2 solutions :
  • Manually put "HidePanel()" inside every node without text : Can't consider this option, because we have alot of those empty nodes it would be too tedious and likely to be forgotten and prone to errors.
  • Set the Panel Visibility set to "Only During Content" : Right now, we're using "Until Superceded or Actor Change", because if we use "Only During Content", this will make it so if the same actor has 2 dialog nodes in a row, the panel will play the "Show" animation on the panel.
User avatar
Tony Li
Posts: 22108
Joined: Thu Jul 18, 2013 1:27 pm

Re: Hide Subtitle panel on empty nodes

Post by Tony Li »

Hi,

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

HideUIOnBlankNodes.cs

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;
public class HideUIOnBlankNodes : MonoBehaviour
{
    void OnConversationLine(Subtitle subtitle)
    {
        DialogueManager.SetDialoguePanel(!string.IsNullOrEmpty(subtitle.formattedText.text));
    }
}
Here's an example scene:

DS_AutoHideUIExample_2023-06-29.unitypackage
Kopire
Posts: 6
Joined: Thu Jun 29, 2023 1:44 pm

Re: Hide Subtitle panel on empty nodes

Post by Kopire »

We will try this, thank you!
Post Reply