Use of Subtitle Interactions

Two Questions

  1. Is there a programmatic way to set the chat mode to be subtitle?

  2. Is there a way to clear the subtitle text field. We are building for a public display and want to clear out the last user interaction before the next user comes in.

Hello @chris.raasch,

Welcome to the Convai Developer Forum!

Here’s how you can achieve your goals:

  1. Activate Subtitle Mode:
    In ConvaiChatUIHandler.cs, you can activate the subtitle mode using the following method:
SetUIType(UIType.Subtitle);
  1. Comment Out SaveLoadSystem (Optional):
    If you want to prevent unnecessary persistence, comment out the SaveLoadSystem-related code in the OnEnable and OnDisable methods of ConvaiChatUIHandler.cs.

  2. Clear Subtitle Text Field:
    There isn’t a direct method for clearing the subtitle text field. However, in SubtitleChatUI.cs, you can create a custom method like this:

public void ClearSubtitleText()
{
    _subtitle.SenderTextObject.text = "";  
    _subtitle.MessageTextObject.text = "";
}

Call this method whenever you need to clear the subtitle text fields.

Thanks will try those today and reply with results.

I used the code from the reply below, and it doesn’t seem to be “sticking” when I move my project to the production computer, I loose the ui selection. Can you provide more explanation on where exactly to set the active interaction type.

Also, I am not sure if this is related, but when i build and run on my computer the npc is found and I can interact. When I try the same code on my production computer, the npc doesn’t seem to be found, I’ve played with the ray length and angles but it seems inconsistent. I only have one npc, in a setup where users are NOT moving around can I just hard assign the npc so it is active on launch?

I didn’t fully understand your first question. Does the issue occur when you open the project on a different computer? Where exactly did you add the code, and what seems to be the problem? If you could provide more details, it would help us understand the issue better.

Regarding your second question, if it’s working on one computer, then the code itself should be fine. If it’s not working on the production computer, it might be due to network issues, firewall settings, or other connectivity problems.

If you can share more details, we’ll be glad to assist you further!

I added the code in ConvaiChatUIHandler.cs, in the onEnable method, I changed it to the following code. However this doesn’t save it to the system and when I pull up the settings, it has the default ChatUI rather than SubtitleUI as the active interface:

private void OnEnable()
        {
            // // Subscribe to the event when saved data is loaded.
            // UISaveLoadSystem.Instance.OnLoad += UISaveLoadSystem_OnLoad;

            // // Subscribe to the event when data is saved.
            // UISaveLoadSystem.Instance.OnSave += UISaveLoadSystem_OnSave;

            SetUIType(UIType.Subtitle);
        }

Hmm, let’s try a different approach. Undo the changes you made in ConvaiChatUIHandler.cs.

Instead, go to UIAppearanceSettings.cs and modify the Start method as follows:

private void Start()
{
    InitializeAppearanceDropdown();

    // 0 - Chatbox
    // 1 - Question Answer
    // 2 - Subtitle
    _appearanceDropdown.value = 2;
    ChangeAppearance(2);
}

This sets the UI to Subtitle by default. The numbers correspond to the different UI types, as noted in the comments.

Give this a try and let me know how it goes!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.