Unity3D基础教程2-1: 游戏对象/物体(GameObjects)

2014-08-06 07:39:11|?次阅读|上传:huigezrx【已有?条评论】发表评论

关键词:Unity3D, 游戏, 虚拟现实|来源:唯设编程网

Unity Manual > User Guide > Building Scenes > GameObjects

Unity 手册->用户指南->建立场景->游戏对象(物体)

GameObjects are the most important objects in Unity. It is very important to understand what a GameObject is, and how it can be used. This page will explain all that for you.


What are GameObjects?游戏对象是什么?

Every object in your game is a GameObject. However, GameObjects don't do anything on their own. They need special properties before they can become a character, an environment, or a special effect. But every one of these objects does so many different things. If every object is a GameObject, how do we differentiate an interactive power-up object from a static room? What makes these GameObjects different from each other?


The answer to this question is that GameObjects are containers. They are empty boxes which can hold the different pieces that make up a lightmapped island or a physics-driven car. So to really understand GameObjects, you have to understand these pieces; they are called Components. Depending on what kind of object you want to create, you will add different combinations of Components to the GameObject. Think of a GameObject as an empty cooking pot, and Components as different ingredients that make up your recipe of gameplay. You can read more about Components here, but we recommend you finish reading this page first.


注意:据上面的翻译理解,GameObject 译成游戏物体比较合适。以下翻译成游戏物体

The GameObject-Component Relationship 游戏物体(对象)-组件关系

We now know that a GameObject contains Components. We'll explore this relationship by discussing the most common Component -- the Transform Component. 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.

我们现在知道一个游戏物体(对象)包含组件。我们将探讨这种包含关系,通过讨论常见的公共组件- Transform 组件(变换组件)。利用任何Unity打开的场景,创建一个新的游戏物体(对象)(在windows上使用Shift+Ctrl+N键或在MAC上Shift+Command+N键),选取它并关注(属性)检视器。

Unity3D基础教程2-1: 游戏对象/物体(GameObjects)
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. It is impossible to create a GameObject in Unity without a Transform Component. All of the GameObject's Transform properties are enabled by its use of the Transform Component. The Transform Component just happens to be critical to all GameObjects, so each GameObject has one. But GameObjects can contain other Components as well.


Unity3D基础教程2-1: 游戏对象/物体(GameObjects)
The Main Camera, added to each scene by default 主摄像机,默认添加到每个场景

Taking a look at the Main Camera GameObject, we 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 thereof) that can be added to any given GameObject.

发表评论0条 】
Unity3D基础教程2-1: 游戏对象/物体(GameObjects)