> 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/player-data-container.md).

# 玩家数据容器

这是一个可脚本化对象，在编辑器中安装了 Convai SDK 且场景中存在 Convai Base Scene Essentials 预制体时，点击播放后会自动生成

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

**默认玩家名称**

您可以为玩家提供一个默认名称。

**玩家名称**

玩家当前的名称；如果您直接使用我们的设置面板，我们会自动保持其更新；如果您使用自定义逻辑，则需要您负责保持其更新，因为我们的转录 UI 会使用此名称在界面中显示它

**说话者 ID**

玩家的说话者 ID。 **请注意，说话者 ID 与您的 API 密钥直接关联，因此每个 API 密钥都应关联一个唯一的说话者 ID。** 如果该布尔值设置为 true，而在 Player Prefs 中未找到说话者 ID，我们会负责创建它。

**未找到时创建说话者 ID**

此布尔值用于让 SDK 决定：如果在 Player Prefs 中未找到该玩家名称，是否为其创建一个唯一的说话者 ID。

### 按钮

#### **重置数据**

它只是会将 **玩家名称** 是位于 **说话者 ID** 字段清空。

#### **复制数据**

将数据复制到系统缓冲区中，以便您可以在任何地方粘贴用于调试。

#### **玩家偏好设置按钮**

1. **加载：** 加载 **玩家名称** 以及关联的 **说话者 ID** 来自玩家偏好设置
2. **保存：** 保存 **玩家名称** 以及关联的 **说话者 ID** 来自玩家偏好设置
3. **删除：** 删除 **玩家名称** 以及关联的 **说话者 ID** 来自玩家偏好设置

### 如何维护玩家数据

Convai 提供了一个预制组件，您可以将其添加到任何 `GameObject` 以使 `PlayerDataContainer` 开箱即用。

选择一个现有的 GameObject，或创建一个新的 `GameObject` 在场景中，并添加 `ConvaiPlayerDataHandler` 组件到您选择的 `GameObject` 它就应该开始工作

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

#### 可选步骤

您也可以通过以下路径创建所需的 Scriptable Object： **`Assets > Convai > Resources`** 然后在项目面板中右键单击并导航到 **`Create > Convai > Player Data`** 并将其命名为 **`ConvaiPlayerDataSO`**

<figure><img src="/files/05076f8c6184e3fb11db2fa3c10d6b35571807e6" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
请确保您将创建的 Scriptable Object 命名为完全 **`ConvaiPlayerDataSO`** 因为我们的系统会查找这个精确名称
{% endhint %}


---

# 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/player-data-container.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.
