> 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/adding-narrative-design-to-your-character/narrative-design-keys.md).

# Narrative Design 键

我们将创建一个简单场景，角色会欢迎玩家，并根据玩家当前的时间段询问他们晚上或早上过得怎么样。

### 步骤 1

在 Playground 中为你的角色启用 Narrative Design。然后，创建一个新的 Section。

### 步骤 2

在新 Section 的 Objective 部分，添加以下文本：

`当前时间段是 {TimeOfDay}。欢迎玩家，并询问他这个 {TimeOfDay} 过得怎么样。`

{% hint style="warning" %}
注意，放在大括号之间的任何字符串都会变成变量。在这里，我们将一天中的时间作为变量添加进来。在 Unity 中，我们可以传入“Morning”或“Evening”，角色就会做出相应回应。
{% endhint %}

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

### 步骤 3

现在，让我们回到 Unity 并进行必要的调整。点击你的 NPC。

点击 **Add Component** 按钮并添加 **Narrative Design Key Controller** 组件。

### 步骤 4

在 **名称** 字段中，输入 **TimeOfDay**。在 **值** 字段中，指定该变量对应的值，可以是 **上午**, **晚上**，或你选择的任何其他内容。

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

就是这样！现在让我们来测试一下。 :tada::sunglasses:

<figure><img src="/files/025f9edc7399878d3e1bfdf721c6a300c5f5af28" 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/adding-narrative-design-to-your-character/narrative-design-keys.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.
