[HOWTO] How To: Change Subtitle Bubble Image

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

[HOWTO] How To: Change Subtitle Bubble Image

Post by Tony Li »

This article explains one way to change an actor's overhead subtitle bubble panel during a conversation.

1. Set up an overhead bubble panel: How To: Show Overhead Conversation Bubble Text. Add the bubble panel as an instance (child) of the actor.

2. Add additional bubble subtitle panels to your actor's GameObject -- for example, with different bubble images for different emotions.

3. Add this script to your actor:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetBubblePanel : MonoBehaviour
{
    public StandardUISubtitlePanel[] bubblePanels; //<-- SET IN INSPECTOR

    void OnConversationLine(Subtitle subtitle)
    {
        if (subtitle == null || subtitle.speakerInfo.transform != this.transform) return;
        int index = Field.LookupInt(subtitle.dialogueEntry.fields, "Bubble");
        if (0 <= index && index < bubblePanels.Length)
        {
            DialogueManager.standardDialogueUI.ForceOverrideSubtitlePanel(bubblePanels[index]);
        }
    }
}
4. Add the script to your actor. Assign the bubble panels, including the original one, to the Bubble Panels list. The original should be element 0.

5. Add a custom Number field "Bubble" to your dialogue entries. When you want to use a different bubble, set the Bubble field to the element number in the script's Bubble Panels list.

Example scene (including script above):

DS_ChangeBubbleImageExample_2024-03-15.unitypackage
Post Reply