转录 UI 系统
转录 UI 系统 - 将转录 UI 与 Convai 的 Unity 插件集成。
最后更新于
这有帮助吗?
这有帮助吗?
private ConvaiChatUIHandler _convaiChatUIHandler;
private void OnEnable()
{
// 在场景中查找并赋值 ConvaiChatUIHandler 组件
_convaiChatUIHandler = ConvaiChatUIHandler.Instance;
if (_convaiChatUIHandler != null) _convaiChatUIHandler.UpdateCharacterList();
}_convaiChatUIHandler.SendPlayerText(input);_convaiChatUIHandler.SendCharacterText(characterName, currentResponseAudio.AudioTranscript.Trim());using Convai.Scripts.Utils;
using UnityEngine;
public class CustomChatUI : ChatUIBase
{
// 在这里实现 ChatUIBase 中要求的方法。
}public override void Initialize(GameObject uiPrefab)
{
// 在这里实例化并设置你的自定义 UI 预制体。
}
public override void SendCharacterText(string charName, string text, Color characterTextColor)
{
// 在这里处理向你的自定义 UI 发送角色文本。
}
public override void SendPlayerText(string playerName, string text, Color playerTextColor)
{
在这里处理向你的自定义 UI 发送玩家文本。
}[Tooltip (用于 customChatUI 的预制体。)]
public GameObject customChatUIPrefab;
private void InitializeUIStrategies()
{
现有 UI 类型
InitializeUI(chatBoxPrefab, UIType.ChatBox);
InitializeUI(questionAnswerPrefab, UIType.QuestionAnswer);
InitializeUI(subtitlePrefab, UIType.Subtitle);
// 自定义 UI 类型
InitializeUI(customChatUIPrefab, UIType.Custom); // 确保在 UIType 枚举中定义 UIType.Custom
}
private void InitializeUI (GameObject uiPrefab, UIType uiType)
{
// 现有代码...
在这里添加你的自定义 UI 初始化
if (uiType == UIType.Custom)
{
CustomChatUI customUIComponent = uiPrefab.GetComponent<CustomChatUI>();
if (customUIComponent == null)
{
Debug.LogError("在预制体上未找到 CustomChatUI 组件。");
return;
}
customUIComponent.Initialize(uiPrefab);
GetUIAppearances[uiType] = customUIComponent;
}
}public enum UIType
{
ChatBox,
QuestionAnswer,
Subtitle,
CustomUI // 你的自定义 UI 类型
}