> 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/gou-jian/components.md).

# 实体和组件

了解物品组件的工作方式

在画布上或实体树中点击一个项目来选择它。然后你会在屏幕右侧的属性面板中看到其组件。不同项目拥有不同的组件，每个组件都会显示特定设置。

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

大多数非交互式项目具有以下组件：

* **Transform**：设置项目的位置、旋转和缩放。如果该项目是另一个项目的子项，位于 [实体树](/creator/content-creator-zh/chang-jing-bian-ji-qi/kai-shi-shi-yong/scene-editor-essentials.md#the-entity-tree)，这些值相对于其父级的值。
* **GLTF**：要加载的 3D 模型。它包括此 3D 模型文件的本地路径。还包含一些用于配置 [碰撞体](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/colliders.md#colliders-on-3d-models) 该模型上的。

你场景中的项目都是 **实体**。场景中的一切都是实体，它们是场景的基本构建块。项目是至少具有位置和可见形状的实体。

## 添加组件

要向任何实体添加组件，请点击 **+** 属性选项卡顶部的 + 符号，然后从列表中选择组件。请参见 [让任意项目变为智能项目](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/make-any-item-smart.md)

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

你可以通过点击其右侧的三点图标，并选择 **删除组件**.

## 从零创建实体

要创建一个全新的实体，请右键单击实体树中的根 **场景** 实体，或任何其他实体，然后选择 **添加子项**

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

这将创建一个空实体，只包含一个 **Transform** 组件。新实体是你所点击的父实体的子项。然后你可以向它添加任何你想要的其他组件，将其塑造成你想要的任何东西。

## 可用组件

以下组件可通过场景编辑器 UI 添加到任何实体：

* **网格渲染器**：根据基础形状（立方体、平面、圆柱体或球体）赋予实体可见形状。
* **网格碰撞器**：赋予实体一个不可见的碰撞体几何。它可以阻止玩家穿过该项目，和/或使其可点击。请参见 [碰撞体](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/colliders.md).
* **材质**：定义拥有一个 **网格渲染器** 组件的实体的颜色、纹理及其他属性。请参见 [材质](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/materials.md).

  <div data-gb-custom-block data-tag="hint" data-style="warning" class="hint hint-warning"><p>**📔 注意**：该项目必须具有 **Mesh Renderer** 组件。它不会影响具有 **GLTF** 可见形状的项目。</p></div>
* **可见性**：定义实体是否不可见。
* **光源**：向实体添加光源。
* **交换材质**：交换拥有一个 **GLTF** 组件的实体的材质。如果 3D 模型有多个网格，你可以分别交换每个网格的材质。
* **音频源**：在实体位置播放来自声音文件的音效。请参见 [声音](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/sounds.md).
* **文本形状**：在 3D 空间中显示文本。请参见 [文本](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/text.md).
* **指针事件**：将实体标记为可点击，并显示悬停提示。

{% hint style="warning" %}
**📔 注意**： **指针事件** 该组件仅提供反馈。要在实体被交互时执行操作，请参见 [让任意项目变为智能项目](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/make-any-item-smart.md)
{% endhint %}

* **多人游戏**：共享对实体发生的任何更改，以便场景中的所有玩家也能看到。它可以配置为仅共享某些组件上的更改。请参见 [无服务器多人协作](/creator/content-creator-zh/chang-jing-sdk7/wang-luo/serverless-multiplayer.md#mark-an-entity-as-synced) 了解更多详情。
* **动画器**：控制具有一个 **GLTF** 3D 模型的实体上的动画播放。请参见 [3D 模型动画](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/3d-model-animations.md).
* **补间**：使实体在一段时间内逐渐移动、旋转或缩放。请参见 [移动实体](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/move-entities.md).
* **广告牌**：使实体始终旋转以面向玩家。请参见 [面向用户](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/entity-positioning.md#face-the-user).
* **头像附着**：将实体附加到玩家的头像上，使其跟随玩家移动。请参见 [将实体附加到头像](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/entity-positioning.md#attach-an-entity-to-an-avatar).
* **视频播放器**：在场景内播放视频，并可通过实体的 **材质**。见 [视频播放](/creator/content-creator-zh/chang-jing-sdk7/mei-ti/video-playing.md).
* **NFT 形状**：在框架内显示 NFT 图片。请参见 [显示 NFT](/creator/content-creator-zh/chang-jing-bian-ji-qi/gou-jian/nfts.md).
* **粒子系统**：从实体位置发射粒子，用于烟雾、火焰或闪光等效果。请参见 [粒子系统](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/particle-system.md).
* **虚拟摄像机**：定义一个自定义摄像机角度，场景可以切换玩家视角到该角度。请参见 [摄像机](/creator/content-creator-zh/chang-jing-sdk7/3d-nei-rong-ji-chu/camera.md).
* **头像修改区域**：更改位于以此实体为中心的区域内玩家的头像行为或外观。实体的缩放决定该区域的大小。请参见 [修改区域](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/modifier-areas.md).
* **摄像机修改区域**：在以此实体为中心的区域内强制玩家摄像机切换为第一人称或第三人称。实体的缩放决定该区域的大小。请参见 [修改区域](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/modifier-areas.md).
* **脚本**：将自定义代码模块附加到实体，并可通过 UI 配置参数。请参见 [脚本组件](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-yong-dai-ma-kuo-zhan/script-component.md).

{% hint style="warning" %}
**📔 注意**：SDK 中还存在其他组件，目前只能通过代码使用。你也可以创建自己的 [自定义组件](/creator/content-creator-zh/chang-jing-sdk7/jia-gou/custom-components.md) 通过代码，这些组件不会有 UI 表现形式，但可以通过代码添加和编辑。

参见 [与代码结合使用](/creator/content-creator-zh/chang-jing-bian-ji-qi/shi-yong-dai-ma-kuo-zhan/overview.md) 了解如何编辑场景代码。

另外请注意，一个实体只能包含 **一个** 每种组件各一个。无法为实体中已存在的组件分配第二个实例。例如，你不能添加两个 **操作** 同一实体的组件。
{% endhint %}

## 智能项目

[智能项目](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items.md) 也可以包含用于控制实体交互性的特殊组件。它们通常是：

* **操作**：列出该项目可以执行的所有可能操作。
* **触发器**：确定何时执行 Actions 组件中的操作。
* **状态**：跟踪项目的当前状态。该状态可用于条件逻辑，仅在项目处于某种状态时触发某些操作。
* **计数器**：跟踪计数器。该计数器可用于条件逻辑，仅在计数器的值等于/大于/小于给定值时触发某些操作。

参见 [智能项目进阶](/creator/content-creator-zh/chang-jing-bian-ji-qi/jiao-hu-xing/smart-items-advanced.md) 了解更多详情。

## 关于实体和组件

场景中的一切都是实体。场景中的所有项目和智能项目都是实体。

实体的所有特性都由其组件决定。它们定义了实体是什么、它在哪里、它听起来如何以及它如何表现。例如，一个 **Transform** 组件会存储实体的坐标、旋转和缩放。一个 **MeshRenderer** 组件会赋予实体可见形状（如立方体或球体），而一个 **材质** 组件会赋予实体颜色或纹理。

组件上的值可以随时间变化。在场景编辑器中，你为这些组件配置初始值。但一旦场景运行，玩家的行为或时间流逝都可能改变这些值。

例如，一个移动平台智能项目有一个初始位置，你可通过其 **Transform** 组件进行设置，但当该项目的操作使其移动后，它的 **Transform** 将保存不同的值。

参见 [实体与组件](/creator/content-creator-zh/chang-jing-sdk7/jia-gou/entities-components.md) 以深入了解这一概念以及它们在 Decentraland 场景中的使用方式。


---

# 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/gou-jian/components.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.
