> 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).

# 叙事设计键

本指南展示了如何动态地将变量传递给叙事设计部分和触发器。

我们将创建一个简单的场景：角色向玩家问候，并根据玩家当前的时段询问他们晚上或早上过得如何。

### 步骤 1

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

### 步骤 2

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

`The time of day currently is {TimeOfDay}. Welcome the player and ask him how his {TimeOfDay} is going.`

{% hint style="warning" %}
请注意，花括号中的任何字符串都会变成变量。在本例中，我们将一天中的时段设为变量。在 Unity 中，我们可以传入 "Morning" 或 "Evening"，角色会相应地作出回应。
{% endhint %}

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FgZ8ofGMLxuNlhdl8th2E%2Fimage.png?alt=media&amp;token=76313e0d-729d-4a92-ad1f-997149264090" alt=""><figcaption></figcaption></figure>

### 步骤 3

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

点击 **添加组件** 按钮，然后添加 **Narrative Design Key Controller** 组件。

### 步骤 4

在 **名称** 字段中，输入 **TimeOfDay**。在 **值** 字段中，指定该变量对应的值，可以是 **Morning**, **Evening**，也可以是你选择的任何其他值。

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FH5GYYl95BIFlKqFB7W28%2FUnity_ND_Keys.png?alt=media&amp;token=e87cf62f-6f21-4fe0-b7c2-0e29234efe5e" alt=""><figcaption></figcaption></figure>

就这样！现在来测试一下吧。 :tada::sunglasses:

<figure><img src="https://2402152281-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEtUJA212Zc1S9ACc8T4l%2Fuploads%2FomZWUaOKtAVd5M4NrO50%2FUnity_ND_Keys_Test.png?alt=media&amp;token=36b4950c-2f19-45b9-a126-991ee01c243e" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
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>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
