Skip to main content

语法指南

大多数文档页面由文本组成。不过,你可以使用额外的语法使页面更易读。

Markdown​

你的页面使用 Markdown 编写。Markdown 文档易于在任何文本编辑器中编辑和预览。以下是一个非常简单的文档页面示例:

# Example page

This is an example page with a title and some text.

VRChat 创作文档使用 Docusaurus 构建。Docusaurus 将你的 Markdown 文件转换为网页:

http://creators.vrchat.com

Example page

This is an example page with a title and some text.

Docusaurus 使用 MDX,它是 Markdown 的扩展。你可以通过多种方式使用 Docusaurus 和 MDX 来增强文档。

tip

你可以点击任何页面底部的"编辑此页面"来了解该页面的创建方式。

预览你的更改​

如果你想向 VRChat 文档提交复杂的更改,应该在本地预览它们。这样可以让你看到更改在网站上的效果。

要预览更改,请按照 GitHub 上的说明操作:

  1. 在 GitHub 上创建创作文档仓库的 fork。
  2. 使用 Git 克隆你的 fork。
  3. 在 Docs/ 文件夹中运行 npm install,通过 npm 安装 Docusaurus。
  4. 在 Docs/ 文件夹中运行 npm run start,通过 npm 启动 Docusaurus。

前置元数据​

前置元数据是关于 markdown 文件的可选数据。你可以用它来改变 Docusaurus 在文档中展示页面的方式。

你可以在文件顶部添加前置元数据,用三个破折号(---)括起来。内容会被解析为 YAML。

---
unlisted: true
---

下表展示了最常用的前置元数据字段。你可以在 Docusaurus 文档中找到完整列表。

名称类型默认值描述建议
slugstringMarkdown 文件名文档的 URL。考虑使用合适的文件名,而不是使用 slug。
toc_min_heading_levelnumber2(##)目录中显示的最小标题级别。不能高于 toc_max_heading_level。考虑创建多个页面代替。
toc_max_heading_levelnumber3(###)目录中显示的最大标题级别。必须在 2 到 6 之间。考虑创建多个页面代替。
unlistedbooleanfalse发布到 creators.vrchat.com 后从侧边栏隐藏该页面。不要对读者可能觉得重要的页面使用 unlisted。
  • 不要使用 title 属性。请使用 Markdown 标题(#)代替。
  • 不要使用 last_update 属性。它会自动计算。

警示块​

你可以使用警示块来突出显示简短的重要信息。警示块在文本中会显得格外醒目。

  • 不要过度使用警示块。
  • 不要覆盖警示块的标题。
:::tip

用于重要的建议或快捷方式。

:::

:::info

用于重要的限制或上下文信息。

:::

:::warning

用于潜在的错误或如何避免它们。

:::

:::danger

用于可能导致不可逆损害的操作。

:::
http://creators.vrchat.com
tip

用于重要的建议或快捷方式。

info

用于重要的限制或上下文信息。

warning

用于潜在的错误或如何避免它们。

danger

用于可能导致不可逆损害的操作。

代码块​

要在页面上包含 UdonSharp 代码,请使用三个反引号创建代码块。这对示例特别有用。

```
// This is an example code block.
Debug.Log("Hello, world!");
```
http://creators.vrchat.com
// This is an example code block.
Debug.Log("Hello, world!");

你可以通过启用其他选项使代码块更易读:

```csharp showLineNumbers title="Assets/Example.cs"
// This is an example code block.
Debug.Log("Hello, world!");
```
http://creators.vrchat.com
Assets/Example.cs
// This is an example code block.
Debug.Log("Hello, world!");

代码标签页​

你可以并排显示 Udon Graph 截图和 UdonSharp 代码。读者可以选择他们偏好的语言,所有代码标签页组件会同步读者的选择。

以下是如何导入和使用 Tabs 和 TabItem 的示例:

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="udon-compiler-language">
<TabItem value="graph" label="Udon Graph">

![A screenshot of the Udon Graph.](/img/worlds/graph-helloworld.png)

</TabItem>
<TabItem value="cs" label="UdonSharp">

```cs showLineNumbers
private void Start()
{
Debug.Log("Hello, world!");
}
```

</TabItem>
</Tabs>
http://creators.vrchat.com

A screenshot of the Udon Graph.