Transcript UI System
Transcript UI System - Integrate transcript UI with Convai's Unity plugin.
Last updated
Transcript UI System - Integrate transcript UI with Convai's Unity plugin.
Last updated
The Dynamic UI system is a feature within the Convai Unity SDK that provides developers a robust system for in-game communication. This feature allows for displaying messages from characters and players and supports various UI components for chat, Q&A sessions, subtitles, and custom UI types. This document will guide you through the integration, usage, and creation of custom UI types of the Dynamic UI feature in your Unity project.
To interact with the chat system, you need to reference the ConvaiChatUIHandler
in your scripts. You can find the Transcript UI prefab in the Prefabs folder.
Here's an example of how to find and assign the handler:
Once you have a reference to the ConvaiChatUIHandler
, you can send messages using the following methods:
Sending Player Text
To send text as the player:
input
: The string containing the player's message.
To send text as a character:
characterName
: The name of the character sending the message.
currentResponseAudio.AudioTranscript
: The transcript of the audio response from the character, trimmed of any leading or trailing whitespace.
While the Dynamic UI system within the SDK provides several pre-built UI types, you may want to create a custom UI that better fits the style and needs of your game and it designed to be extensible, allowing developers to add their custom UI types. This is achieved by inheriting from the ChatUIBase
class and implementing the required methods. The ConvaiChatUIHandler
manages the different UI types and provides a system to switch between them.
To create a custom UI type, follow these steps:
Create a new C# script in your Unity project and define your class to inherit from ChatUIBase
. For example:
Implement the abstract methods from ChatUIBase
. You must provide implementations for Initialize
, SendCharacterText
, and SendPlayerText
:
Add any additional functionality or customization options that your custom UI may require.
To use your custom UI class within the dictionaryConvaiChatUIHandler
, you need to add it to the GetUIAppearances
dictionary. This involves creating a prefab for your custom UI and assigning it in the ConvaiChatUIHandler
.
Here's an example of how to do this:
Create a prefab for your custom UI and add your CustomChatUI
component to it.
Assign the prefab to a public variable in the ConvaiChatUIHandler
script.
Modify the InitializeUIStrategies
method in the ConvaiChatUIHandler
script to include your custom UI type.
Ensure that your custom UI type is added to the UIType
enum:
Now you can set your custom UI type as the active UI from the Settings Panel Settings Panel.
By following these steps, you can integrate your custom UI type into the Dynamic Chatbox system and switch between different UI types at runtime.