One way is to subclass StandardDialogueUI and override Open() and ShowSubtitle().
Override Open() to initialize a list of actors for which you've already shown their name:
Code: Select all
private HashSet<int> actorNamesShown = new HashSet<int>(); // List of actor IDs.
public override void Open()
{
base.Open();
actorNamesShown.Clear();
}
Code: Select all
public override ShowSubtitle(Subtitle subtitle)
{
DialogueActor dialogueActor;
var subtitlePanel = conversationUIElements.standardSubtitleControls.GetPanel(subtitle, out dialogueActor);
subtitlePanel.portraitName.enabled = !actorNamesShown(subtitle.speakerInfo.id);
actorNamesShown.Add(subtitle.speakerInfo.id);
}
Alternatively, you can skip all that and add a small script the characters' GameObjects that uses OnConversationStart and OnConversationLine methods to prepend the actor's name to the subtitle text:
Code: Select all
public class PrependNameToFirstLine : MonoBehaviour
{
public bool firstLine;
// Note: This only work for the conversation's two primary participants.
void OnConversationStart(Transform actor)
{
firstLine = true;
}
void OnConversationLine(Subtitle subtitle)
{
if (firstLine) subtitle.formattedText.text = subtitle.speakerInfo.Name + ": " + subtitle.formattedText.text;
firstLine = false;
}
}