> 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-beta-overview/features/long-term-memory/quick-start.md).

# 快速开始

## 你的第一个跨会话记忆

长期记忆要正常工作需要两件事：必须在 Convai 仪表板中为该角色启用记忆，并且 SDK 必须在每个会话中发送一个稳定的用户标识符。第二部分由 `DeviceEndUserIdProvider`。本指南涵盖从零开始到让角色记住你的最少步骤。

{% hint style="info" %}
**先决条件**

* 你的 Convai API 密钥配置在 **工具 → Convai → 配置**.
* 一个带有 `ConvaiCharacter` 组件且已设置并正常工作的 Unity 场景（角色应能对语音做出响应）。
  {% endhint %}

## 步骤

{% stepper %}
{% step %}
**为你的角色启用记忆**

打开 [Convai 仪表板](https://convai.com) 并选择你的角色。导航到 **记忆 → 记忆设置** 并启用 **长期记忆** 切换开关。

这是一个可选启用的设置——记忆 **默认关闭**。在这里启用之前，角色不会积累或使用记忆。有关仪表板 UI 的完整演练，请参阅 [记忆设置文档](https://docs.convai.com/api-docs/convai-playground/character-customization/memory#memory-settings).

{% hint style="warning" %}
启用记忆会影响该角色在所有部署中的所有会话——不仅仅是你的 Unity 项目。如果该角色与其他团队成员或项目共享，请在启用前协调好。
{% endhint %}

<figure><img src="/files/0819dbfa38f741d656e8dbec8bb5e8219541f541" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**进入播放模式并开始对话**

按 **播放** 在 Unity 编辑器中。与角色开始对话，并分享几条它可以记住的事实——你的名字、你的角色或某个偏好。例如：

> “我叫 Alex。我是夜班的安全官。”

让角色回应，然后 **停止 Play 模式**.
{% endstep %}

{% step %}
**重新进入 Play 模式并验证回忆**

按 **播放** 再次开始与同一角色的新对话。让它回忆它知道的内容：

> "你还记得我是谁吗？"

如果长期记忆正在工作，角色会引用上一会话中的事实，而无需再次告知。
{% endstep %}
{% endstepper %}

{% hint style="success" %}
**预期结果：** 角色会在没有任何提示的情况下提及你的名字或角色。回忆不会逐字照搬——AI 会将存储的记忆自然地综合进回复中。
{% endhint %}

## 刚刚发生了什么

在这无缝体验的背后，有四件事是自动发生的：

1. **身份：** SDK 调用了 `DeviceEndUserIdProvider`，它从 `PlayerPrefs` 读取了一个稳定的 GUID（键： `"convai.end_user_id"`）。在编辑器中，此机器上的每次播放模式会话都会使用相同的 GUID。
2. **连接：** 该 GUID 在会话开始时作为 `end_user_id` 发送到 Convai 服务器。
3. **记忆回忆：** 服务器将该 GUID 解析为内部说话者记录，加载 `speaker_id:character_id` 对的记忆，并在首次回复前将其注入 AI 的上下文中。
4. **记忆存储：** 在第一次会话结束时，后端从对话中提取事实（你的名字、你的角色），并将它们存储为 `MemoryRecord` 分区中的条目。

{% hint style="warning" %}
**编辑器身份说明：** 在 Unity 编辑器中，同一台机器上的所有播放模式会话共享相同的 `end_user_id`。这是为了稳定测试而特意这样设计的。这并不反映玩家构建版本的行为；在玩家构建中，每个物理设备都会获得自己的标识符。请参阅 [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/end-user-identity.md) 以了解完整情况。
{% endhint %}

## 后续步骤

* 要了解用户标识符如何工作，以及如何用你自己的标识符替换它： [终端用户身份](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/end-user-identity.md)
* 要以编程方式启用或禁用记忆，而不是通过仪表板： [在角色上启用记忆](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/enabling-memory-on-characters.md)
* 要从代码中添加、列出或删除记忆记录： [记忆管理 API](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/memory-management-api.md)
* 要查看和管理已积累记忆的用户： [终端用户管理](/api-docs/zh/cha-jian-yu-ji-cheng/unity-plugin-beta-overview/features/long-term-memory/end-user-management.md)

## 结论

在仪表板中启用记忆并使用默认身份提供方后，你的角色会在每次会话中自动积累并回忆用户特定的事实——完全自动化。当你的项目需要用户账户、自定义身份或对记忆内容的直接控制时，本节其余部分会提供实现这些功能的工具。


---

# 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-beta-overview/features/long-term-memory/quick-start.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.
