> 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/ru-men/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\&token=98f0efb0-8490-45d1-8180-3003a9f9a640)

然后在屏幕下方区域，系统会要求你为新的自定义项目命名。

![](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\&token=9331e0f5-8e09-4033-a0e2-158068d35227)

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

![](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\&token=bd6dccd4-6f4f-4b4d-8fae-c8f7c7f435f4)

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

场景中的原始实体不会受到定义自定义项目这一操作的影响。

{% 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 by asking a question.

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

```
GET https://docs.decentraland.org/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/custom-items.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.
