Unity3D说明文档翻译-Introduction to Components

来源:互联网 发布:自动化软件系统工程师 编辑:程序博客网 时间:2024/05/17 17:41

Introduction to Components

组件介绍

As described previously in GameObjects, a GameObject contains Components. We’ll explore this relationship by discussing a GameObject and its most common Component – the TransformComponent. With any Unity Scene open, create a new GameObject (using Shift-Control-N on Windows or Shift-Command-N on Mac), select it and take a look at the Inspector.

在前面的游戏对象里有描述,一个游戏对象包含组件.我们将通过探讨一个游戏对象和它最通常的组件-变换组件来探索此关系.当任何Unity场景打开时,创建一个新游戏对象(使用shift+ctrl+N键(window),shift+Command+N键(mac)),选定它再查看检视面板.

The Inspector of an Empty GameObject

一个空游戏对象的检视面板

 

Notice that an empty GameObject still contains a Name, a Tag, and a Layer. Every GameObject also contains a Transform Component.

注意,一个空游戏对象依然包含一个名称,一个标签和一个层级.每个游戏对象也包含一个转换组件.

The Transform Component

转换组件

It is impossible to create a GameObject in Unity without a Transform Component. The Transform Component is one of the most important Components, since all of the GameObject’s Transform properties are enabled by its use of this Component. It defines the GameObject’s position, rotation, and scale in the game world/Scene View. If a GameObject did not have a Transform Component, it would be nothing more than some information in the computer’s memory. It effectively would not exist in the world.

Unity中创建一个没有转换组件的游戏对象是不可能的.转换组件是最重要的组件之一,因此所有游戏对象在使用在使用此组件时转换组件的属性都是可用的.它定义了游戏对象在游戏的世界/场景视图上的位置,旋转和缩放.如果一个游戏对象没有转换组件,它将仅仅是一些在电脑内存中的一些信息.它实际上不存在于这个世界中.

The Transform Component also enables a concept called Parenting, which is utilized through the Unity Editor and is a critical part of working with GameObjects. To learn more about the Transform Component and Parenting, read the Transform Component Reference page.

转换组件也引出了一个概念叫父子关系,这被用于Unity编辑器且是使用游戏对象的一个重要部分.学习更多关于转换组件和父子关系,阅读转换组件参考页面.

Other Components

其他组件

The Transform Component is critical to all GameObjects, so each GameObject has one. But GameObjects can contain other Components as well.

转换组件对所有游戏对象至关重要,所以每个游戏对象都有一个.不过游戏对象也可以包含其他组件.

The Main Camera, added to each scene by default

主摄像机,默认添加到每个场景

 

Looking at the Main Camera GameObject, you can see that it contains a different collection of Components. Specifically, a Camera Component, a GUILayer, a Flare Layer, and an Audio Listener. All of these Components provide additional functionality to the GameObject. Without them, there would be nothing rendering the graphics of the game for the person playing! Rigidbodies, Colliders, Particles, and Audio are all different Components (or combinations of Components) that can be added to any given GameObject.

再看主摄像机游戏对象,你可以看到它包含一个不同的组件集合.特别地,一个摄像机组件,一个用户界面层,一个光晕层和一个声音监听者.所以这些组件提供游戏对象额外功能.没有它们,人们在使用时将没有任何物理效果渲染.刚体,碰撞检测,粒子和声音都是可添加到任何给定游戏对象上的不同组件(或组件集合).

 

0 0