> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/utilities/notification-system.md).

# 通知系统

Convai 插件自带默认通知，共四个。如下：

## 通知

### 与角色距离不够近

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

<div data-full-width="false"><figure><img src="/files/38d36e86e2f1b84e3d4f8189adf7c70eb1296365" alt=""><figcaption></figcaption></figure></div>

### 过早松开对话按钮

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

<figure><img src="/files/970ba58678c8de22042dad2b9456a2f898a59fe4" alt=""><figcaption></figcaption></figure>

### 检测到麦克风问题

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

<figure><img src="/files/a62963682c921181c27c9c0d103dcd42677c146e" alt=""><figcaption></figcaption></figure>

### 连接问题

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

<div align="center" data-full-width="false"><figure><img src="/files/8c50203f2b9548e05dd202caef6f4656ad4f041e" alt=""><figcaption></figcaption></figure></div>

## 如何添加你自己的通知？

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

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

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

<figure><img src="/files/3ea994a0082eea9e0f1cb2d40ef8b64fc6e6d2fe" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/76828b901e17ed51102dd6babc8b2565d57f61cd" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/eed81ff5ba2ee267ad8645a635bb15b293c069d8" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/9b1f210d09ef253674babad1a80ef1e579e3e5fe" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/bb66698157906f44adcbf1e16e39b79640829a9a" alt=""><figcaption></figcaption></figure>

{% code fullWidth="false" %}

```csharp
NotificationSystemHandler.Instance.NotificationRequest(NotificationType.CharacterStartedListening);
```

{% endcode %}

6. 将参数替换为你创建的 NotificationType。（对于我们的示例， ***NotificationType.CharacterStartedListening***)
7. 确保场景中存在 Convai Notification System。（可从“*Convai/Prefabs/ Notification System*")

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

## Notification Scriptable Object

这个 Scriptable Object 存储通知的信息

* 通知类型
* 通知图标
* 通知标题
* 通知消息

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

<figure><img src="/files/e3c8a8de2fcab59de36191b04c9cc64e736f8a8d" alt=""><figcaption></figcaption></figure>

## 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，但你可以添加更多，或创建一个包含更多通知的新组。

##

<figure><img src="/files/329abf7523605339cafe652c0b32afa2a0dac3fc" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin/utilities/notification-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
