> For the complete documentation index, see [llms.txt](https://docs.decentraland.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/custom-items.md).

# 自定义物品

创建你自己的自定义物品，以便在任何场景中复用。

定义一个自定义物品，方便在你的任何场景中重复使用，或与其他场景创作者共享。自定义物品可以由单个实体组成，也可以包含任意数量的实体。自定义物品可以是现有智能物品的变体，也可以完全自定义，拥有自己定制的模型和功能。

{% embed url="<https://www.youtube.com/watch?v=7cGLu8P7dso>" %}

## 如何定义自定义物品

在 [实体树](/creator/content-creator-zh/chang-jing-bian-ji-qi/kai-shi-shi-yong/scene-editor-essentials.md#the-entity-tree)中的某个实体上右键单击，或者选中多个实体后再右键单击它们。选择 **创建自定义物品**.

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-e2d3666b2958e72bd78207ed4ac8e0f9908e02be%2Fcreate-custom-item.png?alt=media)

随后在屏幕下方区域，你会被要求为新的自定义物品命名。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-ee1372916ffe9ea085734e64823ec5da994b6e21%2Fname-custom-item.png?alt=media)

该物品现在会列在屏幕底部的 **自定义物品** 选项卡中。只有在你的工作区中至少存在一个自定义物品时，此选项卡才会显示。

![](https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-aa8e9586dc8aa8ed34e1d5358f1c072ff821a6f6%2Fcustom-items.png?alt=media)

定义自定义物品时，你可以选择同一层级上的多个实体，但如果实体不共享共同祖先，则不能选择来自不同父级的实体。任何嵌套实体都会自动作为自定义物品的一部分包含进去，无需手动选择。

定义自定义物品这一操作不会影响场景中的原始实体。

{% hint style="warning" %}
**📔 注意**：定义自定义物品时，你会对所选实体上每个组件的状态进行快照（根实体的位置、旋转和缩放除外）。这包括 **操作**, **触发器**, **多人游戏**, **脚本**, **可见性**，以及任何其他组件。

任何智能物品的操作和触发器都会引用它们自己的副本。例如，如果你定义了一个包含电梯和按钮的自定义物品，那么每个电梯副本上的按钮只会控制其所属的那个电梯副本，而不会控制原始电梯副本。
{% endhint %}

### 使用自定义物品

只需将物品从 **自定义物品** 选项卡拖入你的场景即可。

添加后，你可以自由修改自定义物品的任何属性，你所做的更改只会影响 *该副本* 的自定义物品。你也可以编辑或删除创建该自定义物品时所依据的原始物品，这不会影响现有副本或未来副本。

请注意，自定义物品在实体树中的图标会有所不同。在右侧物品属性菜单的顶部，你还会看到它们是从哪个自定义物品创建的。

要删除自定义物品定义，请在 **自定义物品** 菜单中的该物品上右键单击，然后选择 **删除**。此操作不会影响你场景中该物品的任何现有副本，孤立的自定义物品会保持不变。删除自定义物品定义只会将其从自定义物品选项卡中移除。

要重命名自定义物品定义，请在 **自定义物品** 选项卡中的自定义物品定义上右键单击，然后选择 **重命名**.

你不能修改已经创建的自定义物品定义，必须创建一个新的定义并删除原始定义。

### 动态生成自定义物品

每个自定义物品都以复合体的形式存储，复合体是一个描述实体和组件树的文件。这意味着你可以在场景运行时生成自定义物品的新副本，而不必手动放置每个副本。

你可以通过两种方式生成自定义物品：

* **无需代码**：使用 **生成实体** 操作，见 [关于生成实体](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items-advanced.md#about-spawning-entities).
* **使用代码**：使用 `Composite.instance()` 在 SDK 中。见 [复合体](/creator/content-creator-zh/chang-jing-sdk7/jia-gou/composites.md).

### 共享自定义物品

你可以与其他创作者共享你的自定义物品，这样他们就可以在自己的场景中使用它们。

自定义物品会分别存储在本地机器上的独立文件夹中。点击自定义物品选项卡右上角的文件夹图标即可打开该文件夹 <img src="https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-498b8fc602219919fc16af2f71ffd39de109217b%2Ffolder-icon.png?alt=media" alt="Code" data-size="line"> 。

你也可以在你的设备上手动找到这个文件夹：

* 在 Windows 中： *User/AppData/Roaming/creator-hub/Custom Items*
* 在 Mac 中： *Users/username/Library/Application Support/creator-hub/Custom Items*

{% hint style="warning" %}
**📔 注意**： *Library* 文件夹在 Mac 中默认是隐藏的。访问它最简单的方法是打开“前往”>“前往文件夹”，然后输入 *application support/creator-hub*
{% endhint %}

要与他人共享，只需打开自定义物品文件夹并复制该物品的完整文件夹。你可能会想将该文件夹压缩成 zip 以便更容易传输。这个文件夹包含使用你的自定义物品所需的一切。

使用你自定义物品的人随后必须将该物品文件夹解压到他们自己机器上的自定义物品文件夹中。他们可能需要点击刷新按钮 <img src="https://2460066822-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoPnXBby9S6MrsW83Y9qZ%2Fuploads%2Fgit-blob-00fc2759423a0c9c5093d009af76d68292af5108%2Frefresh-icon.png?alt=media" alt="Refresh" data-size="line"> ，该物品才会出现在他们的 **自定义物品** 选项卡中。

任何 **资产** 都存储在自定义物品的文件夹中。这包括该物品引用的任何 3D 模型、图像、脚本、声音和视频。


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/custom-items.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
