For the complete documentation index, see llms.txt. This page is also available as Markdown.

通知系统

通知系统 - 使用 Convai Unity 插件实用工具实现通知。

Convai 插件自带默认通知,共四个。如下:

通知

与角色距离不够近

当你按下对话按钮但附近没有可交互的 NPC 时出现。

过早松开对话按钮

当你在不到 0.5 秒内松开对话按钮时出现。

检测到麦克风问题

当录制的音频输入电平低于阈值时出现。

连接问题

当启动应用程序时没有互联网连接时出现。

如何添加你自己的通知?

添加自定义通知非常简单。

让我们逐步了解如何添加一个“ CharacterStartedListening”通知,以此为例。

  1. 打开脚本 “Convai/Scripts/Notification System/Notification Type.cs。” 此脚本将通知类型存储为枚举。为你想要的通知类型命名,并将其添加到这里。

  1. 右键单击 “Convai / Scripts / Notification System / Scriptable Objects” 并选择 “Create > Convai > Notification System > Notification” 然后创建一个“Notification Scriptable Object。”

  1. 为创建的 Notification Scriptable Object 命名。点击它,并在 Inspector 中按需填写各字段。

  1. 将创建的 Notification Scriptable Object 添加到 “Convai/Scripts/Notification System/Scriptable Objects” 下的 “Convai Default Notification Group” (Notification Group 的详细信息见此****)。

  1. 你的通知现在已经准备好了。最后一步是在需要的地方调用这个通知。比如,如果你创建了“ CharacterStartedTalking ”Notification,请找到角色开始聆听的位置并编写代码。

  1. 将参数替换为你创建的 NotificationType。(对于我们的示例, NotificationType.CharacterStartedListening)

  2. 确保场景中存在 Convai Notification System。(可从“Convai/Prefabs/ Notification System")

所有步骤都已完成,你可以开始测试了!🙂✅

Notification Scriptable Object

这个 Scriptable Object 存储通知的信息

  • 通知类型

  • 通知图标

  • 通知标题

  • 通知消息

要创建新的 Notification Scriptable Object,请在 Project Window 中任意位置右键单击并选择“Create > Convai > Notification System > Notification"

Notification Group Scriptable Object

这个 Scriptable Object 会将 Notification Scriptable Object 作为组进行存储。当请求某个通知时,它会在 Convai Notification System 预制体的 Notification System Handler 脚本中使用指定的 Notification Group 搜索该通知。

你可以根据需要创建不同的 Notification 组。注意:如果你引用的 Notification Group 中没有你想要的 Notification,那么该 Notification 将不会被调用。

Convai Default Notification Group 共有四个 Notification,但你可以添加更多,或创建一个包含更多通知的新组。

最后更新于

这有帮助吗?