Creating Scenes 创建场景

优质
小牛编辑
126浏览
2023-12-01

Scenes contain the objects of your game. They can be used to create a main menu, individual levels, and anything else. Think of each unique Scene file as a unique level. In each Scene, you will place your environments, obstacles, and decorations, essentially designing and building your game in pieces.

场景包含你的游戏中的对象,它们可用于创建一个主菜单、独立关卡(是这个意思吗?)和其他任何东西。可以将每一个独特的场景文件想象成一个独特的关卡,在每个场景中,你可以放置你的环境、障碍和装饰物,用这些碎片拼凑,设计,创建你的游戏。

Instancing Prefabs 实例化预置

Use the method described in the last section to create a Prefab. You can also read more details about Prefabs here. Once you've created a Prefab, you can quickly and easily make copies of the Prefab, called an Instance. To create an instance of any Prefab, drag the Prefab from the Project View to the Hierarchy or Scene View. Now you have a unique instance of your Prefab to position and tweak as you like.

使用上一节描述的方法创建一个预置,你也可以在这里阅读更多有关预置的细节。一旦你创建了一个预置,您可以快速方便地创建一个预置的副本,称之为一个实例。要创建任意预置的实例,从项目视图中拖动预置到层次视图或场景视图中即可。现在你有了一个预置的唯一实例,按照你喜欢的模样定位和调整它。

Adding Component & Scripts 添加组件和脚本

When you have a Prefab or any GameObject highlighted, you can add additional functionality to it by using Components. Please view the Component Reference for details about all the different Components. Scripts are a type of Component. To add a Component, just highlight your GameObject and select a Component from the Component menu. You will then see the Component appear in the Inspector of the GameObject. Scripts are also contained in the Component menu by default.

当你有一个预置或高亮的游戏对象,你可以通过使用组件为它添加额外的功能,请查看组件参考了解关于所有不同组件的详细资料。脚本也是一种组件。要添加一个组件,只需高亮游戏对象,然后从组件菜单中选择一个组件,你将会看到组件出现在对象的检视视图中。脚本也包含在默认组件菜单中。

If adding a Component breaks the GameObject's connection to its Prefab, you can always use GameObject->Apply Changes to Prefab from the menu to re-establish the link.

如果添加一个组件破坏了游戏对象和预置之间的关联,你始终可以通过菜单GameObject->Apply Changes to Prefab重新建立连接。

Placing GameObjects 放置游戏对象

Once your GameObject is in the scene, you can use the Transform Tools to position it wherever you like. Additionally, you can use the Transform values in the Inspector to fine-tune placement and rotation. Please view the Transform Component page for more information about positioning and rotating GameObje

一旦你的游戏对象在场景中,你可以使用变换工具来把它放到任何你喜欢的地方。此外,你可以在检视视图中使用Transform值来微调它的位置和旋转角度。查看更多关于定位和旋转游戏对象的信息Transform Component pagects.

Working with Cameras 使用相机

Cameras are the eyes of your game. Everything the player will see when playing is through one or more cameras. You can position, rotate, and parent cameras just like any other GameObject. A camera is just a GameObject with a Camera Component attached to it. Therefore it can do anything a regular GameObject can do, and then some camera-specific functions too. There are also some helpful Camera scripts that are installed with the standard assets package when you create a new project. You can find them in Components->Camera-Control from the menu. There are some additional aspects to cameras which will be good to understand. To read about cameras, view the Camera component page.

相机是游戏的眼睛。玩家看到的一切都是通过一个或多个摄像机播放的。你可以像其他游戏对象一样定位、旋转、及parent摄像机。相机只是一个附加了相机组件的游戏对象。因此,它可以做任何普通游戏对象可以做的事情,并且还有一些相机特有的功能。还有一些有用的摄像机脚本,它们是在你创建一个新工程时随标准资源包一起安装的。你可以通过菜单Components->Camera-Control找到它们。要了解如何更好地使用相机,请查看Camera component page。

Lights 光源

Except for some very few cases, you will always need to add Lights to your scene. There are three different types of lights, and all of them behave a little differently from each other. The important thing is that they add atmosphere and ambience to your game. Different lighting can completely change the mood of your game, and using lights effectively will be an important subject to learn. To read about the different lights, please view the Light component page.

除了一些极少数的情况,你总是需要为你的场景添加光源。有三种不同类型的光源,它们的表现有所不同,重要的是,它们能为你的游戏增加气氛和氛围。不同的光源可以完全改变你的游戏的情境,有效地利用光源将是一个重要的学习课题。要了解有关不同的光源,请查看Light component page