2014-08-06 07:39:11|?次阅读|上传:huigezrx【已有?条评论】发表评论
关键词:Unity3D, 游戏, 虚拟现实|来源:唯设编程网
关注主摄像机游戏物体(对象),我们可以看到它包含不同的组件集合。具体而言,一个摄像机组件、一个GUI涂层,一个眩光涂层以及一个音频接收器。所有的这些组件都提供了额外的功能给游戏物体(对象)。没有它们,就将没有图形渲染的游戏让人玩!刚体、碰撞器、粒子以及音频都是不同的组件(或它们的组合)可以被添加到任何给定的游戏物体(对象)。
The Transform Component is one of the most important Components. 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. 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. If you would like to learn more about the Transform Component and Parenting, please read the Transform Component Reference page.
变换组件是最重要的组件之一。它定义了游戏物体(对象)在游戏世界里或场景视图里的坐标(位置)、旋转、以及伸缩。如果一个游戏物体(对象)没有一个变换组件,它将只不过是在计算机内存了的一些信息。它将有效的不存在与世界。变换组件还启用了一个被称为父的概念,是通过使用Unity编辑器与游戏物体一起工作的重要组成部分。如果你想学习更多关于变换组件和父,请阅读变换组件参考页。
When you create a script and and attach it to a GameObject, the script appears in the GameObject's Inspector just like a Component. This is because scripts become Components when they are saved. In technical terms, a script compiles as a type of Component, and is treated like any other Component by the Unity engine.
当你创建一个脚本并它放在一个游戏物体(对象)上,这个脚本显示在游戏物体(对象)的检视器里,就像一个组件。这是因为脚本变成组件当它们保存时。在技术方面,一个脚本编译为组件的一种类型,如同通过Unity引擎处理的所有其它组件。
Any public variables you declare in your script will appear editable or linkable in the Inspector of their GameObject. When you are writing a script, you can directly access any member of the GameObject class. You can see a list of all the GameObject class members here. If any of the indicated classes are attached to the GameObject as a Component, you can access that Component directly through the script by simply typing the member name. For example, typing transform is equivalent to gameObject.transform. The gameObject is assumed by the compiler, unless you specifically reference a different GameObject.
在你的脚本里你定义的任何公共变量将显示能编辑或在检视器里能连接它们的游戏物体(对象)。当你编写一个脚本的时候,你可以直接访问GameObject类的所有成员。你可以查看所有GameObject类的成员列表在这里。如果任何指定类作为一个组件被附属于一个游戏物体(对象),你可以访问那个组件,直接经由脚本通过完整键入成员的名称。例如,键入transform是等同于gameObject.transform。gameObject是假定的编译器,除非你特别引用一个不同的GameObject编译器。
Typing this will be accessing the script Component that you are writing. Typing this.gameObject is referring to the GameObject that the script is attached to. You can access the same GameObject by simply typing gameObject. Logically, typing this.transform is the same as typing transform. If you want to access a Component that is not included as a GameObject member, you have to use gameObject.GetComponent() which is explained on the next page.
键入this将访问你正在编写的脚本组件。键入this.gameObjec是引用此脚本附加的GameObject。键入this.transform与键入transform一样。如果你想访问一个没有被GameObject成员包含的组件,你必须使用gameObject.GetComponent(),这是在下一页说明的。