[Solved] How to grab the current speaker name

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Remon8399
Posts: 7
Joined: Sun Dec 09, 2018 12:59 pm

[Solved] How to grab the current speaker name

Post by Remon8399 »

Hi, I want to ask how to grab/pass the CURRENT speaker name into UI text component. :lol:

Not control by Subtitle Panel -> Standard UI Subtitle UI Element -> visibility (Only during content), because I want make sure Actor and Conversant portrait image and name are always show while talking. Then add the current speaker name to other side UI that show in the image that I shared.

Here is the image.
Last edited by Remon8399 on Wed Dec 12, 2018 11:44 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: [ASK] How to grab the current speaker name

Post by Tony Li »

Hi,

If I understand you correctly, assign Speaker Text to all of the subtitle panels' Portrait Name fields.

If that doesn't do what you want, you can write a small script with an OnConversationLine method. The property Subtitle.speakerInfo.Name contains the speaker's name. Example:

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class SetSpeakerText : MonoBehaviour {
    public UnityEngine.UI.Text speakerText; // Assign in inspector.
    void OnConversationLine(Subtitle subtitle) {
        speakerText.text = subtitle.speakerInfo.Name;
    }
}
Another option is to write a subclass of StandardUISubtitlePanel and override the SetContent method. Then use this subclass on your subtitle panels instead of StandardUISubtitlePanel.
Remon8399
Posts: 7
Joined: Sun Dec 09, 2018 12:59 pm

Re: [ASK] How to grab the current speaker name

Post by Remon8399 »

Thank you. That is what I want exactly.
User avatar
Tony Li
Posts: 22057
Joined: Thu Jul 18, 2013 1:27 pm

Re: [ASK] How to grab the current speaker name

Post by Tony Li »

Happy to help!
Post Reply